Erlang – get

Erlang get

In this guide, we will discuss Erlang get. This method is used to get the value of a particular key in the map.

Syntax

get(key,map)

Parameters

  • key − This is the key for which the value needs to be returned.
  • 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:get("a",Map1)]).

Output

The output of the above program is as follows.

1

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply