Actions
Bug #12947
closedMultiline if statements behave differently than inline if statements for flip flop
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
Description
For an inline if statement, a numerical range literal in a conditional behaves like flip flop matching against $.
Parsed here.
printf first\nsecond\nthird\nforth\nfifth\n | ruby -ne 'print if 2..4'
second
third
forth
However when we switch it to a multiline if statement, it behaves like a regex (ie an object, so true).
Parsed here.
$ printf first\nsecond\nthird\nforth\nfifth\n | ruby -ne 'if 2..4; print; end'
first
second
third
forth
fifth
Actions
Like0
Like0Like0Like0