[erlang-questions] Field name to tuple element number at compile time

Colm Dougan colm.dougan@REDACTED
Wed Aug 27 17:14:03 CEST 2008


On Wed, Aug 27, 2008 at 4:01 PM, Joel Reymont <joelr1@REDACTED> wrote:
> Suppose I have -record(foo, { bar, baz }). I understand that I can do
> record_info(fields, foo) and get a list of fields at compile time.
>
> Is there a way to translate bar into 2 at compile time as well?

I think #foo.bar does what you want.

Colm



More information about the erlang-questions mailing list