aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/doc/src/maps.xml
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2016-04-23 00:17:04 +0200
committerBjörn-Egil Dahlberg <[email protected]>2016-04-27 15:26:54 +0200
commiteeac08ca0ed6358a87f265f87a62bea8d0feb3b1 (patch)
tree66f9efd7ee71387f062747325a4bfe66b9e03e35 /lib/stdlib/doc/src/maps.xml
parentcb410cd727824f3dc0038759b16e29a31c4aba83 (diff)
downloadotp-eeac08ca0ed6358a87f265f87a62bea8d0feb3b1.tar.gz
otp-eeac08ca0ed6358a87f265f87a62bea8d0feb3b1.tar.bz2
otp-eeac08ca0ed6358a87f265f87a62bea8d0feb3b1.zip
stdlib: Document maps:update_with/3,4
Diffstat (limited to 'lib/stdlib/doc/src/maps.xml')
-rw-r--r--lib/stdlib/doc/src/maps.xml36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/stdlib/doc/src/maps.xml b/lib/stdlib/doc/src/maps.xml
index 97a7438890..bf45461e2b 100644
--- a/lib/stdlib/doc/src/maps.xml
+++ b/lib/stdlib/doc/src/maps.xml
@@ -381,6 +381,42 @@ error</code>
</desc>
</func>
+ <func>
+ <name name="update_with" arity="3"/>
+ <fsummary></fsummary>
+ <desc>
+ <p>Update a value in a <c><anno>Map1</anno></c> associated with <c><anno>Key</anno></c> by
+ calling <c><anno>Fun</anno></c> on the old value to get a new value. An exception
+ <c>{badkey,<anno>Key</anno>}</c> is generated if
+ <c><anno>Key</anno></c> is not present in the map.</p>
+ <p>Example:</p>
+ <code type="none">
+> Map = #{"counter" => 1},
+ Fun = fun(V) -> V + 1 end,
+ maps:update_with("counter",Fun,Map).
+#{"counter" => 2}</code>
+ </desc>
+ </func>
+
+ <func>
+ <name name="update_with" arity="4"/>
+ <fsummary></fsummary>
+ <desc>
+ <p>Update a value in a <c><anno>Map1</anno></c> associated with <c><anno>Key</anno></c> by
+ calling <c><anno>Fun</anno></c> on the old value to get a new value.
+ If <c><anno>Key</anno></c> is not present
+ in <c><anno>Map1</anno></c> then <c><anno>Init</anno></c> will be associated with
+ <c><anno>Key</anno></c>.
+ </p>
+ <p>Example:</p>
+ <code type="none">
+> Map = #{"counter" => 1},
+ Fun = fun(V) -> V + 1 end,
+ maps:update_with("new counter",Fun,42,Map).
+#{"counter" => 1,"new counter" => 42}</code>
+ </desc>
+ </func>
+
<func>
<name name="values" arity="1"/>
<fsummary></fsummary>