Options to accumulate from a List without an intermediate

Arul Dhesiaseelan aruld at acm.org
Fri Jan 4 22:07:08 PST 2013


Cool, explicit typing is much better. Thanks for the hint.

On Fri, Jan 4, 2013 at 7:17 PM, Brian Goetz <brian.goetz at oracle.com> wrote:

> Here are the working versions. I had to cast to MultiFunction<Album,
>> Track> and apply Accumulators.<Track, Integer> before groupBy to break
>> cyclic inference, as it failed to compile because of java: incompatible
>> types: Cannot instantiate inference variables T because of an inference
>> loop.
>>
>
> Yes, we're working on these compiler issues.
>
>
>> #1
>> final List<Track> tracks =
>> albums.stream().mapMulti((**MultiFunction<Album, Track>) (collector,
>> element) -> collector.yield(element.**tracks)).into(new
>> ArrayList<Track>());
>>
>
> Better than casting is to provide explicit type arguments:
>
>   .mapMulti((Collector<Track> c, Album a) -> ...)
>
>


More information about the lambda-dev mailing list