[erlang-questions] If Condition vs. Multiple Function Clauses
Richard A. O'Keefe
Mon Jun 17 01:19:31 CEST 2013
On 16/06/2013, at 1:30 AM, Steve Davis wrote:
> Yep, that would be a better, more consistent way to go...
> if M == N -> a();
> M > N -> b();
> _ -> c()
Let's see, this says
"Should the test M == N succeed, compute a().
Otherwise, should the test M >N succeed, compute b().
Otherwise, take a new variable that has never been given
any value whatsoever; should that variable, contrary to
all sane expectation, somehow magically turn out to be
bound to a succeeding test, compute c()."
Just how is the "_" supposed to get a value here?
By the way, anyone who is really suffering from the lack of 'else'
if M < N -> c()
; M > N -> b()
; ?else -> a()
and be done with it, although putting M == N there instead would
make it more obvious to one's readers, should one _have_ readers.
More information about the erlang-questions