[erlang-questions] : eep: multiple patterns

Mats Cronqvist mats.cronqvist@REDACTED
Thu May 15 13:40:56 CEST 2008


Raimo Niskanen wrote:
> On Thu, May 15, 2008 at 01:27:55PM +1200, Richard A. O'Keefe wrote:
>   
>> I don't like vague suggestions that
>> "It is rather common to check the value of an expression with a
>>      case expression and do the same actions in some of the cases."
>> I want to see *actual cases*.
>>     
>
> But on this one I have experienced so many *actual cases*
> myself to accept it as an inconveniance. A solution
> to the multiple patterns to one branch problem would
> be convenient, indeed.
>   
 +1
  i don't know where ro'k gets his code examples from, but i for one 
have seen tons and tons of code where many patterns winds up in the same 
branch.
  i find virding's suggestion [1] much nicer though;

foo(Pat11, ...) when Guard1 ;
foo(Pat12, ...) when Guard2 ;
foo(Pat13, ...) when Guard3 ->
    ...;


case ... of
    Pat1 when Guard1 ;
    Pat2 when Guard2 -> ...;
    ...
end

  as for the "~=" operator; i guess i don't see the point.

  mats


[1] 
http://www.erlang.org/pipermail/erlang-questions/2008-March/033784.html)




More information about the erlang-questions mailing list