cannot find symbol on identity operation in lambda

Talden talden at gmail.com
Wed Nov 28 00:09:42 PST 2012


On Wed, Nov 28, 2012 at 6:03 PM, Brian Goetz <brian.goetz at oracle.com> wrote:

> The problem is that the type of the stream returned by map() is
> Stream<Integer>, not IntStream.
>
> If you wanted an IntStream, you'd want to explicitly convert to ints:
>
>    ...stream().map(i -> (int) i).sum()
>

Would it be correct (and possibly more expressive) to use a method
reference for the unboxing in this case?

    ...stream().map(Integer::intValue).sum();

(I'm aware you were really illustrating why it didn't resolve to Integer ->
int but thought it worth noting the another representation of the solution)

--
Aaron Scott-Boddendijk


More information about the lambda-dev mailing list