Re: Why do some people shun `if`?

"Michael P." <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <20210817120350.5b376f83@aesop>
On Mon, 16 Aug 2021 16:39:51 +0800
Vance Shipley <[email protected]> wrote:

> Why I find 'if' awkward is that when I test a condition for the success
> path and have a fall through clause for the fail path the semantics don't
> match with 'true'.
>
>         if
>              Foo == 42 ->
>                   ok;
>              true ->
>                   {error, Foo}
>         end.

I cannot identify any "falling through":
no 'C-switch-case-no-break',
not in the "true" = 'C-switch-default' or 'else'.

I think I remember having employed some
`-define(if_not, true)`
when negation-or-ing all previous conditions
seemed too "dangerous".

~M

--

But who will test the tests?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.