File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -106,14 +106,22 @@ Example:
106106
107107[source,java]
108108----
109+ import java.util.Map;
110+ import static fj.P.*;
111+ import fj.data.Option;
112+ import fj.data.TreeMap;
113+ import fj.P2;
114+
109115// Regular Java
110- public Integer albuquerqueToLA(Map> map) {
111- Map m = map.get("Albuquerque");
112- if (m != null) return m.get("Los Angeles"); // May return null.
116+ public Integer albuquerqueToLA(Map<String, Map<String, Integer>> map) {
117+ Map<String, Integer> m = map.get("Albuquerque");
118+ if (m != null)
119+ return m.get("Los Angeles"); // May return null.
113120}
121+
114122// Functional Java with product and option types.
115- public Option albuquerqueToLA(TreeMap, Integer>() map) {
116- return m .get(p("Albuquerque", "Los Angeles"));
123+ public Option<Integer> albuquerqueToLA(TreeMap<P2<String, String>, Integer> map) {
124+ return map .get(p("Albuquerque", "Los Angeles"));
117125}
118126----
119127
You can’t perform that action at this time.
0 commit comments