News for hackers. Stuff that matters.
Re:Understanding map, filter, and fold by GlennS on Monday December 24, 2012 @11:17AM (#4963234)
I recently started a Java job after having avoided it in favour of better languages for some time. I've found the Google Guava library makes Java programming a lot more bearable: https://code.google.com/p/guava-libraries/

Thinks that will make your life easier

* Collections2.filter() -> this is just filter()

* Collections2.transform() -> this is map()

* ImmutableMap.of() -> for when you need to create a quick lookup

You still have to make an anonymous inner class every time you want to pass a function as an argument though.

Re:Understanding map, filter, and fold by ollysb on Wednesday December 26, 2012 @12:46AM (#4968317)
Yeah, I actually wrote some similar functions for java when I first started experimenting with ruby on the side. I agree it's a big improvement on for loops but there's still a lot of line noise; the anonymous class(as you mention) and having to passing the collection into a static method which is never great. Importing Collections2 statically does make it a bit more pleasant though.