Erlang - find


Advertisements

This method is used to find if a particular key exists in the map.

Syntax

find(key,map)

Parameters

  • key − This is the list which needs to be converted to a map.

  • map − This is the map in which the key needs to be searched.

Return Value

Returns the value if the key is found in the map.

For example

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

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

Output

The output of the above program is as follows.

{ok,1}
erlang_maps.htm
Advertisements