ArrayFactory SAM type / toArray

Brian Goetz brian.goetz at oracle.com
Sun Oct 7 14:52:03 PDT 2012


That presumes you know the size of the result, or are willing to 
tolerate truncation/underflow.  There are cases where the stream knows 
the size but the client does not, and in those cases, treating array as 
a destination leaves the user with no way to get an array without extra 
copying.

On 10/7/2012 3:38 PM, Andrey Breslav wrote:
> Just to repeat on this thread:
>
> I don't see why we need toArray() on Streams at all: we can make it work with .into() by providing corresponding Destination implementations:
>
> stream().into(new ArrayDestination(Class/Lambda/whatever)).array()
>
> And I doubt that there is such a huge number of use cases for creating arrays from streams that this solution isn't good enough.
>
> --
> Andrey Breslav
> http://jetbrains.com
> Develop with pleasure!
>
>


More information about the lambda-libs-spec-observers mailing list