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

Erlang Map Merge Method

Erlang Map

This method is used to merge2a map.

Syntax

merge(map1,map2)

Parameter

  • map1 −This is the first map that needs to be merged.

  • map2 −This is the second map, which needs to be merged with the first map.

Return Value

a map, which is a map1and map2of merge.

-module(helloworld). 
-export([start/0]). 
start() ->
   Lst1 = [{"a",1},{"b",2},{"c",3}], 
   Lst2 = [{"d",4},{"e",5},{"f",6}], 
   
   Map1 = maps:from_list(Lst1, 
   Map2 = maps:from_list(Lst2, 
   io:fwrite("~p~n",[maps:merge(Map1,Map2]).

Output Result

The output of the above program is as follows.

#{"a" => 1,"b" => 2,"c" => 3,"d" => 4,"e" => 5,"f" => 6}

Erlang Map