I’m just wondering where this syntax documented:
1 > 2 || raise("error")
I have tried use it as condition:
1 > 2 || p "test"
but it doesn’t work:
SyntaxError: (irb):9: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
1 > 2 || p "test"
^
from C:/Ruby193/bin/irb:12:in `<main>'
What you have doesn’t work because you need parenthesis:
Note that
or(andand) has a different precedence than&&/||and thus will work without parenthesis (and with what you’re doing makes more semantic sense):as will
unless: