Advertisement
otakana

erlang record accessors ?

Oct 8th, 2020
4,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.26 KB | None | 0 0
  1. -define(PROPERTY_GETTER(RecType,Field), Field(Rec)->Rec#RecType.Field ).
  2. -define(PROPERTY_SETTER(RecType,Field), Field(Rec,Value)->Rec#RecType { Field = Value } ).
  3.  
  4. -record(test,
  5.     {
  6.     field1,
  7.     field2,
  8.     field3
  9.    }).
  10.  
  11. ?PROPERTY_GETTER(test,field1).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement