[erlang-questions] Finding records in List
Bengt Kleberg
bengt.kleberg@REDACTED
Fri Jan 14 09:03:56 CET 2011
Greetings,
I too consider the use of a record in the function head better. I
apologise for any confusion my first example may have caused.
bengt
On Thu, 2011-01-13 at 16:17 +0100, David Mercer wrote:
> On Thursday, January 13, 2011, Bengt Kleberg wrote:
>
> > is_name_and_age( Person, Name, Age ) ->
> > (Person#person.name =:= Name) andalso (Person#person.age =:= Age)
>
> Question about style: is there any preference between what Bengt wrote, and:
>
> is_name_and_age(#person{name = Name, age = Age}, Name, Age) -> true;
> is_name_and_age(_,_,_) -> false.
>
> In fact, I think I like Bengt's better, since it is more clear about intent,
> but I'd have written it as the latter figuring that that was more idiomatic.
> Are records in match specifications out of favor? (To a certain extent, if
> they are, good.)
>
> Cheers,
>
> DBM
>
More information about the erlang-questions
mailing list