Pattern matching: Skipping the rest of a tuple

Joel Reymont joelr1@REDACTED
Wed Dec 28 20:19:54 CET 2005


Folks,

Is it possible to write a function to pattern-match on tuples of  
various sizes _without_ using  element(X, Tuple)?

I'm dealing with records of different length and would like to say  
things like

match({record1, _, 20, _/rest}) -> ...
match({record2, 30, _/rest}) -> ...
etc.

I don't believe there is a syntax for "I don't care about the rest of  
the tuple". It looks to me like I would need to supply _ for every  
element that I'm ignoring.

Is that right?

I know about { ..., _ = _ } but I think it only works on assignment.

	Thanks, Joel

--
http://wagerlabs.com/








More information about the erlang-questions mailing list