From f2740784f82ac3eec2e8669d1fb7b2c0493c008b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Lipt=C3=A1k?= Date: Mon, 6 Nov 2017 19:51:53 -0500 Subject: [PATCH] Correct product types example --- src/jbake/content/features.adoc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/jbake/content/features.adoc b/src/jbake/content/features.adoc index 84f3121..bcfa027 100644 --- a/src/jbake/content/features.adoc +++ b/src/jbake/content/features.adoc @@ -106,14 +106,22 @@ Example: [source,java] ---- +import java.util.Map; +import static fj.P.*; +import fj.data.Option; +import fj.data.TreeMap; +import fj.P2; + // Regular Java -public Integer albuquerqueToLA(Map> map) { - Map m = map.get("Albuquerque"); - if (m != null) return m.get("Los Angeles"); // May return null. +public Integer albuquerqueToLA(Map> map) { + Map m = map.get("Albuquerque"); + if (m != null) + return m.get("Los Angeles"); // May return null. } + // Functional Java with product and option types. -public Option albuquerqueToLA(TreeMap, Integer>() map) { - return m.get(p("Albuquerque", "Los Angeles")); +public Option albuquerqueToLA(TreeMap, Integer> map) { + return map.get(p("Albuquerque", "Los Angeles")); } ----