[erlang-questions] untyped records
Karolis Petrauskas
k.petrauskas@REDACTED
Tue Jul 2 22:01:31 CEST 2013
Hi,
Its a proplist wrapped to a {struct, _}. You can access its
fields as follows:
{struct, X} = {struct,[
{code,1372793577767},
{desc,"e7iOSxy6PYQiMRk87r5cHK4DVAUj5SzI"},
{units,"g|Kg"}
]}.
proplists:get_value(desc, X).
Karolis
On Tue, Jul 2, 2013 at 10:46 PM, Tim <erlang@REDACTED> wrote:
> Greetings,
>
> I'm getting an untyped record from a web form submission. io_lib:format("~p", [MyRecord]) displays:
>
> {struct,[{code,1372793577767},
> {desc,"e7iOSxy6PYQiMRk87r5cHK4DVAUj5SzI"},
> {units,"g|Kg"}]}
>
> Now, I know if I define a record myself, I can access fields using the format: Name#type.field
>
> but in this case the type of record is unknown.
>
> MyRecord#struct.desc returns a 'record struct undefined' error at compile time.
>
> Can I access the fields of this record without deconstructing it?
>
> Cheers.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list