diff options
author | Björn-Egil Dahlberg <[email protected]> | 2014-05-26 16:39:15 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2014-05-26 16:39:15 +0200 |
commit | 3ac10682f7558e39eda8f850387eff67b4354b00 (patch) | |
tree | c8798039468171db114bd4d7c35059aa8c4aed47 /lib/stdlib/src | |
parent | 444bdf0310288cb3ccbd6af28927a5504618ec3f (diff) | |
parent | 6b6cd01b607a1bfcf61bb6d5f4cc3fe9b37445db (diff) | |
download | otp-3ac10682f7558e39eda8f850387eff67b4354b00.tar.gz otp-3ac10682f7558e39eda8f850387eff67b4354b00.tar.bz2 otp-3ac10682f7558e39eda8f850387eff67b4354b00.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r-- | lib/stdlib/src/maps.erl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/stdlib/src/maps.erl b/lib/stdlib/src/maps.erl index fd6d56fa47..4ef1638e6d 100644 --- a/lib/stdlib/src/maps.erl +++ b/lib/stdlib/src/maps.erl @@ -23,7 +23,8 @@ fold/3, map/2, size/1, - without/2 + without/2, + get/3 ]). @@ -142,6 +143,21 @@ values(_) -> erlang:nif_error(undef). %%% End of BIFs +-spec get(Key, Map, Default) -> Value | Default when + Key :: term(), + Map :: map(), + Value :: term(), + Default :: term(). + +get(Key, Map, Default) -> + case maps:find(Key, Map) of + {ok, Value} -> + Value; + error -> + Default + end. + + -spec fold(Fun,Init,Map) -> Acc when Fun :: fun((K, V, AccIn) -> AccOut), Init :: term(), |