|
|
|
|
|
by exelib
5049 days ago
|
|
This is, because you can't Java. How you will find out, where you use first_names = [p.first_name for p in people]
? More verbose, but right way in Java is like (you can do this better with enums and/or guava, it's just example): class PersonTransformer implements Transformer {
public Object transform(Object o) {
return ((Person)o).getFirstName();
}
}
and then: Collection<String> firstNames = CollectionUtils.collect(people, new PersonTransformer());
You can reuse it and, more important, you can search for it. Same for second example. |
|
A couple days back I commented Java, by making some things harder than needed, induces programmers to over-engineer and build things for needs they don't have and to think that's perfectly normal. Think about what you just wrote.