English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Mapping is a data structure with a variable number of keys-Composite data type associated with values. Each key-value association in the mapping is called an association pair. The key and value parts of the pair are called elements. The number of association pairs is called the size of the mapping.
The following program demonstrates an example of how to use the Map data type.
Here we define a Map M1It has2a map.map_size is a built-in function defined in Erlang, which can be used to determine the size of a map.
-module(helloworld). -export([start/ start() -> M1 = #{name=>john,age=>25}, io:fwrite("~w",[map_size(M1)]).
The output of the above program is as follows.
2
Some other methods applicable to maps are as follows.
Serial Number | Methods and Descriptions |
---|---|
1 | This method is used to generate a map from a list. |
2 | This method is used to find if a specific key exists in the map. |
3 | This method is used to get the value of a specific key in the map. |
4 | This method is used to determine if a specific key is defined as a key in the map. |
5 | This method is used to return all keys from the map. |
6 | This method is used to merge2A map. |
7 | This method is used to add a key-value pair to the map. |
8 | This method is used to return all values from the map. |
9 | This method is used to remove the key-value from the map. |