Records & pattern matching

Fredrik Thulin ft@REDACTED
Mon Apr 17 05:34:10 CEST 2006


On Monday 17 April 2006 04:19, Jérémie Lumbroso wrote:
> Hello,
>
> I am trying to do a regular pattern matching using the #record{name =
> "Me", _='_'} construct to do regular pattern matching. But it does
> not seem to work as expected (I am not using the match_object method
> of anything). Am I obligated to explicitly define my tuplet for the
> pattern matching, i.e. do {record,
> _, _, _, "Me", _}?

You only have to specify the fields you want to match on, so you write

	case X of
	   #record{name = "Me"} ->
		...

not

	case X of
	   #record{name = "Me", _ = '_'} ->

/Fredrik



More information about the erlang-questions mailing list