10.7 Nested Records

Beginning with Erlang/OTP R14, parentheses when accessing or updating nested records can be omitted. Assume the following record definitions:

  1. -record(nrec0, {name = "nested0"}).
  2. -record(nrec1, {name = "nested1", nrec0=#nrec0{}}).
  3. -record(nrec2, {name = "nested2", nrec1=#nrec1{}}).
  4.  
  5. N2 = #nrec2{},

Before R14, parentheses were needed as follows:

  1. "nested0" = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0.name,
  2. N0n = ((N2#nrec2.nrec1)#nrec1.nrec0)#nrec0{name = "nested0a"},

Since R14, the following can also be written:

  1. "nested0" = N2#nrec2.nrec1#nrec1.nrec0#nrec0.name,
  2. N0n = N2#nrec2.nrec1#nrec1.nrec0#nrec0{name = "nested0a"},