3 ms·
Adding to #1 : Using static imports to import the newHashMap() method can make the statement even shorter : final Map<String, Map<String, Integer>> lookup =
by haasted 15y ago
Adding to #1 :
Using static imports to import the newHashMap() method can make the statement even shorter :
final Map<String, Map<String, Integer>> lookup = newHashMap();
This serves to make the code far more readable.
- ooohhhddeeaarrr 15y agoIf I were writing the code to use, I would do exactly that. Since it was a explanatory tutorial, I wanted people to see what was happening. Later on I've used static imports after explaining what classes they need to look at for the code. I totally understand your point of view though.
- guard-of-terra 15y agoIn bolts, it's Map<String, Map<String, Integer>> lookup = Cf.hashMap(); Which is as short and also doesn't require static imports. Bolts are the state of art FP library for java. https://bitbucket.org/stepancheg/bolts/src/tip/src/main/java/ru/yandex/bolts/collection/example/ListFExample.java#cl-22 https://bitbucket.org/stepancheg/bolts/src/tip/src/main/java... some examples in tests
- michaelcampbell 15y agoSadly not in maven repo yet so my company can't use it. I have played around some with functional java (functionaljava.org) and Op4j. Have you compared bolts to either of those?
- guard-of-terra 15y agoAs far as I know, functional java was used as inspiration, but bolts were much more suitable for day to day tasks (a lot of pragmatic code already there). No idea about the recent development in fj, they probably made some improvements in the meantime, too.