Erlang - 元素



此方法返回元組中的第 N 個元素。

語法

element(N,Tuple)

引數

  • N − 需要返回的元組中的位置。

  • 元組 − 需要返回第 N 個元素的元組。

返回值

此方法返回元組中的第 N 個元素。

例如

-module(helloworld). 
-export([start/0]). 

start() -> 
   io:fwrite("~p~n",[element(2, {a, b, c})]).

輸出

執行上述程式後,將得到以下結果。

b
erlang_bifs.htm
廣告
© . All rights reserved.