[erlang-questions] : Simple multi-case

Peter Lund <>
Mon Nov 13 21:57:36 CET 2006


or
case getstatus(Id) of
    X when X==free; X==online ->
        doX();
    busy ->
        doY()
end,


Raimo Niskanen skrev:
> Or nest them:
>     case case getstatus(Id) of
>              free -> x;
>              online -> x;
>              busy -> y
>          end of
>         x -> doX();
>         y -> doY();
>     end.
>
> On Fri, Nov 10, 2006 at 01:21:39PM +0100, Christian S wrote:
>   
>>> For now that possible only as
>>>   case getstatus(Id) of
>>>      S when (S==free) orelse (S==online) -> doX(), doZ(), ok;
>>>      busy -> doY()
>>>   end
>>>       
>> Do =
>> case getstatus(Id) of
>>   free    -> x;
>>   online -> x;
>>   busy    -> y
>> end,
>>
>> case Do of
>>   x -> doX();
>>   y -> doY();
>> end.
>>
>> Not less typing, but perhaps a more table-like overview of what to do
>> and thus more readable code.
>> _______________________________________________
>> erlang-questions mailing list
>> 
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>     
>
>   





More information about the erlang-questions mailing list