Erlang - 刪除



此方法用於從對映中刪除鍵值對。

語法

remove(key,map)

引數

  • − 需要從對映中刪除的鍵。

  • 對映 − 需要刪除鍵的對映。

返回值

返回已刪除鍵的對映。

例如

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

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

輸出

以上程式的輸出如下:

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