ArrayFactory SAM type / toArray

Brian Goetz brian.goetz at
Wed Sep 19 14:28:12 PDT 2012

> Presumably because you don't know the size of the array until the
> lambda is called if this is on Stream.

Right, in the stream case, you may not know the target size, but the 
stream implementation very well may.  Making the toArray(T[]) even less 
useful for streams, and a toArray(ArrayFactory<T>) more useful.

> I think that you should just overload .into with a factory so you
> could even pre allocate collections.

But how does that help if you really want an array?  (And, if you're 
talking about overloading into with a factory that produces an array, 
the only difference is whether you call it into() or toArray()).

(BTW, there are some moderately compelling type-inference-limitation 
reasons to not overload into()).

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