What I'm trying to do:
result = (not question?) \
and ( \
condition \
or ( \
comparer == compared and another_question? \
) \
)
The goal is to have complicated and / or logic and still have it be readable.
The problem with the above attempted syntax is that it some how messes up parenthesis in ruby's parser, so console says that the error is in a file that this code isn't in. (though it's in the call stack)
without the back slashes, I get these:
syntax error, unexpected kAND, expecting kEND (SyntaxError)
and
syntax error, unexpected kOR, expecting ')'
any ideas on how to properly do this?
Remove the space after the backslash in another_question? \
. You're escaping the space rather than the newline, which causes a syntax error.
Note you don't need to escape every newline.
result = (not question?) \
and (
condition \
or (
comparer == compared and another_question?
)
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With