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
erlang_bifs.htm
Advertisements