无涯教程-Erlang - put函数

83 阅读1分钟

此方法用于将键值对添加到Map映射。

put - 语法

put(key1,value1,map1)
  • key1     - 这是需要添加到Map的键。

  • value1 - 这是与key1关联的值,需要将其添加到Map中。

  • map1   - 这是需要添加键值的映射。

put - 返回值

具有添加的键值的原始Map映射。

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

start() -> Lst1=[{"a",1},{"b",2},{"c",3}], Map1=maps:from_list(Lst1), io:fwrite("pn",[maps:put("d",4,Map1)]).

上面程序的输出如下-

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

参考链接

www.learnfk.com/erlang/erla…