3 ms·
Rubocop actually enforces this as a default style rule. But note the idea only works in statement-oriented languages. When if ... else ... constructs are an ex
by nonameiguess 6y ago
Rubocop actually enforces this as a default style rule.
But note the idea only works in statement-oriented languages. When if ... else ... constructs are an expression, both arms need to be evaluated for type checking purposes, which means both arms need to exist. Then you have language like R where you're free to use if ... else ... as keywords and statement if you like, but it's generally advised to use the ifelse function instead because it auto-vectorizes over multi-dimensional arguments.