Simple question

UAB/L/K Ingela Anderton konsult OTP <>
Tue Aug 28 14:31:03 CEST 2001


If you want to read about this in the documentation look under 
Erlang Extensions Since 4.4 (I know it is not self-evident that there
is the place to look ;-)). 

Richard Carlsson wrote:
> 
> On Tue, 28 Aug 2001, Nico Weling wrote:
> 
> > Hi Erlang freaks,
> 
> Hi!
> 
> > I need OR within an case clause. ...
> > Is this possible, and if, how is the syntax.
> 
> Try this:
> 
>  	case Name of
> 	    X when X == peter; X == klaus; X == carsten -> 
>  			io:format("Is a man~n",[]);
>  	    X when X == anna; X == birgit; X == petra -> 
>  			io:format("Is a woman~n", []);
>  	    _ -> 
>  			io:format("Is a Zombie~n", [])
>  	end.
> 
> In other words, in a guard, you can have a ';'-separated sequence of
> alternative conditions (a disjunction), where each condition is a
> ','-separated sequence of boolean tests (a conjunction).
> 
> (You could also use 'if' instead of 'case' for the above.)
> 
>   /Richard
> 
> 
> Richard Carlsson ()   (This space intentionally left blank.)
> E-mail: 	WWW: http://www.csd.uu.se/~richardc/
-- 
/m.v.h Ingela

//The highway of life is always under construction. //

 	        |\      _,,,--,,_  ,)
                /,`.-'`'   -,  ;-;;' 
               |,4-  ) )-,_ ) /\
              '---''(_/--' (_/-'

Ericsson Utvecklings AB 

Cellular/Mobile: +46 70 636 78 68 







More information about the erlang-questions mailing list