[erlang-questions] untyped records

Thomas Allen thomas@REDACTED
Tue Jul 2 21:59:59 CEST 2013


Is this a record or a tagged tuple? It looks like the latter.

Perhaps this will work for you:

{struct, Props} = R,
V = proplists:get_value(k, Props),
%% ...

Thomas


On Tue, Jul 2, 2013, at 12:46 PM, Tim 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