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

Loïc Hoguin essen@REDACTED
Sun Jul 22 14:32:29 CEST 2018


Neither.

The problem with this and the list comprehension equivalent

     [io:format("Message: ~s~n", [Msg]) || Msg /= undefined]

is that it will confuse people who never encountered it before.

But if one or both of these forms were teached to beginners and everyone 
was using them, then there'd be no problem in using them anymore.

I'd love if they became more popular.

Cheers,

On 07/22/2018 02:25 PM, Viktor Söderqvist wrote:
> Hey everyone,
> 
> I've seen these short-circuit operators with a non-boolean second
> operand, usually where the second operand is doing some side-effect and
> the return value is not important. It seems to be a trend. Example:
> 
>      Msg /= undefined andalso io:format("Message: ~s~n", [Msg]),
> 
> I this good or bad style?
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list