此方法用于获取映射中特定键的值。

get - 语法

get(key,map)
  • key     -  这是需要为其返回值的键。

  • Map   -  这是需要在其中搜索键的Map。

get - 返回值

如果在Map上找到键,则返回值。

-module(helloLearnfk). 
-export([start/0]). 

start() ->   
   Lst1=[{"a",1},{"b",2},{"c",3}], 
   Map1=maps:from_list(Lst1), 
   io:fwrite("~p~n",[maps:get("a",Map1)]).

上面程序的输出如下。

1

参考链接

https://www.learnfk.com/erlang/erlang-get.html