Passing in record name to a function
Mon Oct 7 01:08:30 CEST 2002
Louis Stamsma wrote:
> I would like to write a generic function that updates a field in a
> record (returning a new version of the record). For this purpose I would
> like to give the function a parameter indicating which field to update.
> Is this possible ?
You can't access a record field by using a variable for the field name. It
must be a fixed field name (atom) instead.
However, you could simulate such a function, by passing the value of
'record_info(fields, your_record)' as a parameter, like I did here:
More information about the erlang-questions