The following is invalid:
true || File.exist? 'touch'
SyntaxError: unexpected tSTRING_BEG, expecting end-of-input
true || File.exist? 'touch'
^
However, if you remove the true ||
, or use brackets around 'touch'
, it's valid:
File.exist? 'touch'
=> false
true || File.exist?('touch')
=> true
Why is the combination of the true ||
and not using brackets invalid syntax?
Doing a search for SyntaxError: unexpected tSYMBEG
only got https://github.com/bbatsov/rubocop/issues/1232 , and doing a search for SyntaxError: unexpected tSTRING_BEG
seemed to mainly get people who'd made some sort of typo such as RoR: syntax error, unexpected tSTRING_BEG, expecting ')' and Ruby syntax error, unexpected tSTRING_BEG, expecting ':' (SyntaxError)