Hi John Mercier !
Thank you for you comment :)
I didn't know about Function.identity(), and, since I like to have the more explicit code possible, I tried it, but I obtained an error.
Function.identity()
error: incompatible types: no instance(s) of type variable(s) T exist so that Function<T,T> conforms to ToIntFunction<? super Integer>
After some googling, I founded this stackoverflow thread and replace the i->i by Integer::intValue instead, which worked too.
i->i
Integer::intValue
Nice! I think identity() returns an Integer in this case and mapToInt expects an int. There is no unboxing going on here. Sorry for the confusion.
identity()
mapToInt
int
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi John Mercier !
Thank you for you comment :)
I didn't know about
Function.identity()
, and, since I like to have the more explicit code possible, I tried it, but I obtained an error.After some googling, I founded this stackoverflow thread and replace the
i->i
byInteger::intValue
instead, which worked too.Nice! I think
identity()
returns an Integer in this case andmapToInt
expects anint
. There is no unboxing going on here. Sorry for the confusion.