Erlang – is_key

Erlang is_key

In this guide, we will discuss Erlang is_key. This method is used to determine if a particular key is defined as a key in the map.

Syntax

Is_key(key,map)

Parameters

  • key − This is the key which needs to be determined if it is a key in the map.
  • map − This is the map in which the key needs to be searched.

Return Value

Returns true if the key is found else false is returned.

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:is_key("a",Map1)]).

Output

The output of the above program is as follows.

true

Next Topic : Click Here

This Post Has 2 Comments

Leave a Reply