Closed cal101 closed 4 years ago
This makes sense. I agree with 1. and 2. But we should use ofAll instead of allOf to be consistent with our existing naming scheme. I like 'ofAll' because autocompletion and API are side-by-side to 'of' (=> better UX).
On help let's discuss it first.
So, as I understood there are a few things to take care of:
of()
overloads that don't use varargsofAll()
for arrays and other collection typesIs there anything else you have in mind?
@pivovarit I've thought about this topic. I prefer to align to standard Java API instead of a 3rd party API like Guava.
In Java, it is common practice to have of(T)
and of(T...)
, e.g. see Java's Stream API.
If no one complains, I will close this issue.
See also
If no one complains, I will close this issue.
Regardless of the fact if there's something to be done here, it feels like it's a part of https://github.com/vavr-io/vavr/issues/2125
Hi!
We are using guava for some time now for immutable collections. We are revisiting decisions from time to time and I am looking at vavr again after the name change. For example guava ImmutableList has companion methods of
of()
and 'copyOf()', too, like for example vavrArray
hasof
andofAll
. When test converting some code from Java arrays and ImmutableList to vavr Array I noticed thatArray.of(<some-java-array>)
has to be used compared toImmutableList.copyOf(<some-java-array>)
. That is especially interesting for me because at some time in the past guava switched fromImmutableList.of(<some-java-array>)
toImmutableList.copyOf(<some-java-array>)
. It took a little bit of work to change that in our code base but I think they are right on this. If you want to create a collection from some other collection that should include from arrays in my opinion. AndXXX.of()
should be kept for enumerated single values. That '...' is converted to an array is just an implementation detail and I suggest following the guava and the JDK (9? 10?) example andThanks for reading so far ;-)