[erlang-questions] Orelse and andalso as short-hand for case

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Mon Jul 23 13:05:37 CEST 2018


On Sun, Jul 22, 2018 at 9:09 PM Jachym Holecek <freza@REDACTED> wrote:

> # Viktor Söderqvist 2018-07-22:
> >
> >     Msg /= undefined andalso io:format("Message: ~s~n", [Msg]),
> >
> > I this good or bad style?
>
> It is horrible style. Pain to read, pain to modify, pain to reason about.
>
> Simple clear question deserves a simple clear answer. :-)
>
>
​I don't like the style either, mostly because it messes with the types.
andalso and orelse expects boolean expressions, but the style used breaks
that format. However, something like

[x || Msg /= undefined]

doesn't.​


-- 
J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180723/83ed10f1/attachment.htm>


More information about the erlang-questions mailing list