Record comprehension

Craig Dickson crd@REDACTED
Wed Jul 12 23:45:48 CEST 2000


Well, that would be because a record is really just a tuple with the name of
the record type as the first member. Thus
#tester{first=first,second=second,third=third} is really just
{tester,first,second,third}. Though I'm a little surprised that the lookup
of H#tester.second didn't cause a runtime error due to H not being the right
kind of record.

Craig

----- Original Message -----
From: "Martin Logan" <martin@REDACTED>
To: <erlang-questions@REDACTED>
Sent: Wednesday, 12 July 2000 02:36 pm
Subject: Record comprehension


> I seem to have encountered somthing interesting with records. If anyone
> has any insight please share.
>
> -module(test).
> -export([test/0]).
>
> -record(tester, {first, second, third}).
>
>
> test() ->
>     H = {first, second, third},
>     R = #tester{first=first, second=second, third=third},
>     {H#tester.second, R#tester.second}.
>
>
> OUTPUT:
>
> 32> c(test).
> {ok,test}
> 33> test:test().
> {third,second}
>
> Thanks,
> Martin Logan
>




More information about the erlang-questions mailing list