In this guide, we will discuss Erlang put. This method is used to add a key value pair to the map.
Syntax
put(key1,value1,map1)
Parameters
- key1 − This is key which needs to be added to the map.
- Value1 − This is the value associated with key1 which needs to be added to the map.
- map1 − This is map to which the key value needs to be added.
Return Value
The original map with the added key value.
For example
-module(helloworld). -export([start/0]). start() -> Lst1 = [{"a",1},{"b",2},{"c",3}], Map1 = maps:from_list(Lst1), io:fwrite("~p~n",[maps:put("d",4,Map1)]).
Output
The output of the above program is as follows −
#{"a" => 1,"b" => 2,"c" => 3,"d" => 4}
Next Topic : Click Here
Pingback: Erlang - merge | Adglob Infosystem Pvt Ltd
Pingback: Erlang - Maps | Adglob Infosystem Pvt Ltd