Options to accumulate from a List without an intermediate
Brian Goetz
brian.goetz at oracle.com
Fri Jan 4 21:17:22 PST 2013
> 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