Erlang - 鍵



此方法用於返回地圖中的所有鍵。

語法

keys(map)

引數

  • map − 這是需要返回其所有鍵的地圖。

返回值

返回地圖中的鍵列表。

例如

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

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

輸出

上述程式的輸出如下。

["a","b","c"]
erlang_maps.htm
廣告
© . All rights reserved.