Here's an unexpected find. Something of a very basic Ruby issue that I haven't happened to run into before:
a = "a"
if a
test = "yes" if a == "a" else "no"
else
test = "no"
end
Running this yields the error:
syntax error, unexpected kELSE, expecting kEND
Looks like the nested oneliner spills out into the enclosing if statement. What's the generalized solution for this? Not using a oneliner inside an exploded if statement? (It works when exploding the enclosed conditional because it is terminated by an end
keyword.
BTW, This is a minimized contrived example, so no need to explain its stupidity or question why I'd do this. I'm looking for a general explanation of how to prevent ruby oneliner if statements from spilling into enclosing conditional scopes.