[erlang-questions] Erlang elseif
Fri Nov 21 10:37:54 CET 2008
> You can implement
> If <expression1> == true then <result1>
> elseif <expression2> then <result2>
> else <result3>
> in erlang as follows
> if <expresson1> == true ->
> <expression2> ->
> true ->
A very important limitation in erlang's "if" expression is that the
tests needs to be guards. If it is okay to execute all tests, every
time, then one can of course do
E1 = <expression1>,
E2 = <expression2>,
E1 -> <result1>;
E2 -> <result2>;
true -> <result3>
I've had a feeling that there is an if-else chain expression called
"cond" just waiting to happen?
The cond would in be identical to
case Test1 of
true -> Result1;
case Test2 of
true -> Result2;
case Test... of
true -> Result...
false -> yay
I dont know where I got this impression that "cond" was waiting to
happen. Is it not? Does it need an EEP? Are there objections to it?
Does it need a reference implementation?
More information about the erlang-questions