[erlang-questions] Dynamically access record fields

ok@REDACTED ok@REDACTED
Mon Feb 11 01:07:58 CET 2013


> On Sat, Feb 9, 2013 at 2:33 PM, Dmitry Kolesnikov

> What I was saying was that you can't do something like
>
> Field = a,
> V2 = setelement(#foo.Field, V1, "A+")

Yes.  Like it says on the box, "records".
You can't do this in Pascal, Modula, Modula2, Oberon, Ada, C, ...
Records are not dictionaries and do not store field names.
That's pretty much the _point_ of records, actually.

But you *CAN* do

    Index = #foo.a,
    V1 = setelement(Index, V1, "A+")

It's all spelled out in the manual.
In this case, section 9.3, "Accessing Record Fields",
second paragraph.





More information about the erlang-questions mailing list