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

Jachym Holecek freza@REDACTED
Sun Jul 22 21:10:34 CEST 2018


Hi,

# Viktor Söderqvist 2018-07-22:
> 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?

It is horrible style. Pain to read, pain to modify, pain to reason about.

Simple clear question deserves a simple clear answer. :-)

BR,
	-- Jachym



More information about the erlang-questions mailing list