New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question: Singleton Seq of Array #89
Comments
It's simple. The use-case of Seq.of((Object) new String[] { "" });
Less pressure on the GC due to unneeded array references? |
Thanks, I thought I've overseen s.th. I like varargs, too. A little bit nasty is the need for An alternative for creating a singleton would be another method name, like My question is clarified, the issue can be closed :-) Thanks again!
|
You're telling me? I'm maintaining a huge Java-6 compatible API (jOOQ). I could kick someone for not having introduced
Yes, that would match the existing
Yes. Good enough for "us". You can do better, in Javaslang :-) |
That's fair enough :-) |
I've just thought of another reason why you should overload |
Thank you for sharing! That was insightful, there is so much to learn! Also interesting how deep and thoughtful little things are which seem to be trivial at first sight. |
I think the proper work around is |
@jbgi: Yes, you're right |
@jbgi it is 6 chars longer than |
Just for the sake of completeness:
It's the |
Interesting point, I haven't thought of this... This is probably relevant only when passing a |
Hi Lukas,
I'm not convinced about the
java.util.stream.Stream.of()
API. There areStream.of(T t)
respectivelySeq.of(T t)
Stream.of(T... values)
respectivelySeq.of(T... values)
which does not allow us to create a Stream/Seq of an Array, i.e.
Seq.of(new String[] { "hello" })
is aSeq<String>
instead of aSeq<String[]>
Workaround:
Seq.of(new String[][]{{ "" }})
, which is uglyJust want to hear your opinion about the practical value of having a special API for a singleton Array Seq.
And also: What is the use case for a
Stream.of(T t)
. If there would be only aStream.of(T... values)
we could also callStream.of(t)
!? Looking at the implementation of java.util.stream.Stream.of(T t) I see a difference, but from the API perspective I don't see the point.- Daniel
The text was updated successfully, but these errors were encountered: