In this guide, we will discuss Erlang element. The method returns the Nth element in the tuple.
Syntax
element(N,Tuple)
Parameters
- N − The position in the tuple which needs to be returned.
- Tuple − The tuple for which the Nth element needs to be returned.
Return Value
The method returns the Nth element in the tuple.
For example
-module(helloworld). -export([start/0]). start() -> io:fwrite("~p~n",[element(2, {a, b, c})]).
Output
When we run the above program, we will get the following result.
b
Next Topic : Click Here
Pingback: Erlang - BIFS | Adglob Infosystem Pvt Ltd