3.13 Record

A record is a data structure for storing a fixed number of elements. It has named fields and is similar to a struct in C. However, a record is not a true data type. Instead, record expressions are translated to tuple expressions during compilation. Therefore, record expressions are not understood by the shell unless special actions are taken. For details, see the shell(3) manual page in STDLIB).


  1. -module(person).
  2. -export([new/2]).
  4. -record(person, {name, age}).
  6. new(Name, Age) ->
  7. #person{name=Name, age=Age}.
  9. 1> person:new(ernie, 44).
  10. {person,ernie,44}

Read more about records in Records. More examples can be found in Programming Examples.