Erlang - from_list



此方法用於從列表生成對映。

語法

from_list(Lst)

引數

  • Lst − 這是需要轉換為對映的列表。

返回值

基於提供的列表生成對映。

例如

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

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

輸出

上述程式的輸出如下。

#{"a" => 1,"b" => 2,"c" => 3}
erlang_maps.htm
廣告
© . All rights reserved.