Tuesday, May 25, 2010

Pathetic

Collection expectedIds =
    Collections2.transform(fooCollection,
                           new Function () {
                             @Override
                             public Id apply (Foo foo) {
                               return foo.getId();
                             }
                          });

2 comments:

Tomasz Skutnik said...

Once I tried to program in this style. After three or four classes I've found that standard Java constructs are simpler and much more readable (even for me). Not to mention tool support (Eclipse) and (even more important) maintainability by your next maintenance programmer.

steck said...

This is just a map over some collection? Yow.

I tried a little F# hacking the other day, and was annoyed that if you wrote

open List;

as you might do in OCaml, you get a compiler error that tells you to instead explicitly qualify everything in the List module, e.g., List.map. I guess they're trying to protect you from type misuse but the type inferencer would tell you that you're using `map' from wrong module. I want the freedom to hang myself!