[erlang-questions] record with dynamic item name

Roberto Ostinelli <>
Sun Aug 28 12:46:10 CEST 2011


Hi list,

is there any way to retrieve a record item whose identifier is in a
variable? For instance:

-record(state, {
    type = 1
}).

These do not work:

Type = type,
Val = #state.Type.

nor

#state{Type = Val}.

I have a routine which basically just needs to lookup record items and I'd
like to avoid writing 20 time the same code just because Type changes.

Thank you,

r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110828/a67bc97c/attachment.html>


More information about the erlang-questions mailing list