Comparator
Marc Petit-Huguenin
marc at petit-huguenin.org
Mon Jul 15 08:53:21 PDT 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Hi,
I am trying to use a comparator on a Map.Entry<String, Integer> stream, and I
am not sure why this does not compile:
.sorted(Comparator.comparing(Map.Entry::getValue))
error: reference to comparing is ambiguous
error: incompatible types: Cannot instantiate inference variables T because of
an inference loop
(interestingly the second error was not present when using a build from last week)
These two compile:
.sorted(Comparator.comparing((ToIntFunction<Map.Entry<String,
Integer>>)Map.Entry::getValue))
.sorted(Comparator.comparing((Map.Entry<String, Integer> entry) ->
entry.getValue().intValue()))
Thanks.
- --
Marc Petit-Huguenin
Email: marc at petit-huguenin.org
Blog: http://blog.marc.petit-huguenin.org
Profile: http://www.linkedin.com/in/petithug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iQIcBAEBCAAGBQJR5BrvAAoJECnERZXWan7Em7UP/1YH+kupYW2bcANs+BrfgbdW
npniz63F1GDjWC9IqAd0FREGXEcoAqQCYN3r292APQ4kirSxP4imV8LC9Gof86B/
VGNoxMLpxIxAELWA6Ps1EANFypFf19Rot1fCAAcKBqon4gGBf/IC+BhOkydtnm74
FVOytk8jkjSWz8DikZ7Z48xBVcR6wMQrPAjh/II0zMt+gqXZY1nLeFFEoaQJDyHs
u4wxySolO7BrF63s/mxz89PuxLA5vuEMVdehTOgcvz3QZu2KZJ+gk7Y96PZOMdoU
eMGfpIPxNlab5pRJXPoHn7XiiWPo+VKHs7SkInhqU49HL/uFNZjdn+rH1gbN4M7H
sn6rMt1b9+BNVad8mlMwby5REE1+qoC9ActisEQlHKlwc+W1Suz+oKjfBWhzjQmv
tHvhaTscSFwY0SewR1D3YaCBAcGllUU0078yWqTCRHeTVmuCjfqDAMTPn515tVsr
Rds4uIdESoBY3kDc3OazZEKO9TD7OdsSuhAMeIv7aooNQqtQ1JlC93D8od8lXfC1
25/Tyt6WXT1pp1TMURvzIw2YNgLXrTWi1wjQaQm5yqeBgfcKdPGbjzyYbAaQlA1i
PiGPfyIyg/GtTGeyO4M8mgbAo/p0w2PQU0iK+oQDWDEoKDt1wQNZMLf6VzQSpKqm
/1syZfGWNEl3J7fuvh/o
=h+Kp
-----END PGP SIGNATURE-----
More information about the lambda-dev
mailing list