From 5a19f97ebb036f7e9f6e2c735d9f52662b20a6a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 10 Apr 2015 12:18:59 +0200 Subject: Document the new {badmap,Term} and {badkey,Key} exceptions --- lib/stdlib/doc/src/maps.xml | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/doc/src/maps.xml b/lib/stdlib/doc/src/maps.xml index f766c843be..59c26d9896 100644 --- a/lib/stdlib/doc/src/maps.xml +++ b/lib/stdlib/doc/src/maps.xml @@ -40,6 +40,9 @@ Returns a tuple {ok, Value} where Value is the value associated with Key, or error if no value is associated with Key in Map.

+

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

Example:

> Map = #{"hi" => 42}, @@ -95,8 +98,10 @@

Returns the value Value associated with Key if Map contains Key. - If no value is associated with Key then the call will - fail with an exception. +

+

+ The call will fail with a {badmap,Map} exception if Map is not a map, + or with a {badkey,Key} exception if no value is associated with Key.

Example:

@@ -116,6 +121,10 @@ Map contains Key. If no value is associated with Key then returns Default.

+

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

Example:

> Map = #{ key1 => val1, key2 => val2 }. @@ -134,7 +143,9 @@ val1

Returns true if map Map contains Key and returns false if it does not contain the Key. - The function will fail with an exception if Map is not a Map. +

+

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

Example:

@@ -154,6 +165,9 @@ false

Returns a complete list of keys, in arbitrary order, which resides within Map.

+

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

Example:

> Map = #{42 => value_three,1337 => "value two","a" => 1}, @@ -189,6 +203,10 @@ false Merges two maps into a single map Map3. If two keys exists in both maps the value in Map1 will be superseded by the value in Map2.

+

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

Example:

> Map1 = #{a => "value_one", b => "value_two"}, @@ -222,6 +240,10 @@ false replaced by value Value. The function returns a new map Map2 containing the new association and the old associations in Map1.

+

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

+

Example:

> Map = #{"a" => 1}. @@ -241,6 +263,9 @@ false The function removes the Key, if it exists, and its associated value from Map1 and returns a new map Map2 without key Key.

+

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

Example:

> Map = #{"a" => 1}. @@ -276,6 +301,9 @@ false The fuction returns a list of pairs representing the key-value associations of Map, where the pairs, [{K1,V1}, ..., {Kn,Vn}], are returned in arbitrary order.

+

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

Example:

> Map = #{42 => value_three,1337 => "value two","a" => 1}, @@ -291,8 +319,11 @@ false

If Key exists in Map1 the old associated value is replaced by value Value. The function returns a new map Map2 containing - the new associated value. If Key does not exist in Map1 an exception is - generated. + the new associated value. +

+

+ The call will fail with a {badmap,Map} exception if Map1 is not a map, + or with a {badkey,Key} exception if no value is associated with Key.

Example:

@@ -310,6 +341,9 @@ false

Returns a complete list of values, in arbitrary order, contained in map M.

+

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

Example:

> Map = #{42 => value_three,1337 => "value two","a" => 1}, -- cgit v1.2.3