English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Erlang Map put Method

Erlang Map

This method is used to add key-value pairs to the map.

Syntax

put(key1,value1,map1)

Parameter

  • key1 −This is the key that needs to be added to the map.

  • Value1 −This is the key1Associated values that need to be added to the map.

  • map1 −This is the map that needs to add keys.

Return Value

Original map with added keys.

Online 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 Result

The output of the above program is as follows-

#{"a" => 1,"b" => 2,"c" => 3,"d" => 4}

Erlang Map