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).

Examples:

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

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