[erlang-questions] If Condition vs. Multiple Function Clauses
Mon Jun 17 15:06:29 CEST 2013
Yep, you changed my mind (again). I wasn't thinking about this correctly.
Thanks very much for your replies,
On Jun 16, 2013, at 6:19 PM, "Richard A. O'Keefe" <> wrote:
> 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'
> can just
> -define(else, true).
> and then
> 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