Erlang – find

Erlang find

In this guide, we will discuss Erlang find. 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}

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply