[erlang-questions] How to display a record ?

Sean Cribbs seancribbs@REDACTED
Sun Jun 7 16:00:16 CEST 2009


Try this:

io:format("~p~n", [A])

Remember records are just tagged tuples at runtime, so you'll get 
something like so:

{person,"john","1234"}

Sean

Gamoto wrote:
> Hello,
> Is it possible to display a record  instead of its content ?
> Example:
>
> -record (person,{name,phone}).
> init()->
> A=#person{name="john",phone="1234"},
> io:format([A]),		*** hangs ***
> %% but
> io:format("~s~n",[A1#person.phone]).     *** display phone ***
>
>
> ________________________________________________________________
> erlang-questions mailing list. See http://www.erlang.org/faq.html
> erlang-questions (at) erlang.org
>
>
>   



More information about the erlang-questions mailing list