Streams factories in Stream
Stephen Colebourne
scolebourne at joda.org
Tue Apr 23 17:05:01 PDT 2013
On 23 April 2013 20:14, Brian Goetz <brian.goetz at oracle.com> wrote:
>> Stream.of()/empty()
>> Naive like me use Stream.of() for empty but loose the optimized version
>> empty().
>> Isn't it better to get rid of empty() and optimized of()
>
> Except its not optimized. You've already paid the cost of boxing the args into an empty array. :(
Agreed on the need for the method (unfortunately). My original email
suggested leaving empty() named as is, or changing to ofEmpty(). I'm
not a huge fan of just Stream.of(), as although it is consistent with
the other of(...) methods, it is less clear to read.
In a time-series library I wrote recently, I went with ofEmpty(), and
I think it turned out quite clear. Writers get the IDE help from a
common prefix, and readers get something meaningful.
Stephen
More information about the lambda-dev
mailing list