From f3c55529dbc9cb3bf8801bea9b64da78b9b73d5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Sun, 10 Apr 2016 23:09:54 +0200 Subject: stdlib: Document maps:take/2 --- lib/stdlib/doc/src/maps.xml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/maps.xml b/lib/stdlib/doc/src/maps.xml index 0f58f19421..97a7438890 100644 --- a/lib/stdlib/doc/src/maps.xml +++ b/lib/stdlib/doc/src/maps.xml @@ -300,6 +300,30 @@ false + + + + +

+ The function removes the Key, if it exists, and its associated value from + Map1 and returns a tuple with the removed Value and + the new map Map2 without key Key. + If the key does not exist error is returned. +

+

+ The call will fail with a {badmap,Map} exception if Map1 is not a map. +

+

Example:

+ +> Map = #{"a" => "hello", "b" => "world"}. +#{"a" => "hello", "b" => "world"} +> maps:take("a",Map). +{"hello",#{"b" => "world"}} +> maps:take("does not exist",Map). +error +
+
+ -- cgit v1.2.3 From eeac08ca0ed6358a87f265f87a62bea8d0feb3b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Sat, 23 Apr 2016 00:17:04 +0200 Subject: stdlib: Document maps:update_with/3,4 --- lib/stdlib/doc/src/maps.xml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'lib/stdlib/doc/src') 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 + + + + +

Update a value in a Map1 associated with Key by + calling Fun on the old value to get a new value. An exception + {badkey,Key} is generated if + Key is not present in the map.

+

Example:

+ +> Map = #{"counter" => 1}, + Fun = fun(V) -> V + 1 end, + maps:update_with("counter",Fun,Map). +#{"counter" => 2} +
+
+ + + + + +

Update a value in a Map1 associated with Key by + calling Fun on the old value to get a new value. + If Key is not present + in Map1 then Init will be associated with + Key. +

+

Example:

+ +> Map = #{"counter" => 1}, + Fun = fun(V) -> V + 1 end, + maps:update_with("new counter",Fun,42,Map). +#{"counter" => 1,"new counter" => 42} +
+
+ -- cgit v1.2.3