From: nobu@... Date: 2016-11-16T05:28:27+00:00 Subject: [ruby-core:78164] [Ruby trunk Bug#12947] Multiline if statements behave differently than inline if statements for flip flop Issue #12947 has been updated by Nobuyoshi Nakada. Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED ---------------------------------------- Bug #12947: Multiline if statements behave differently than inline if statements for flip flop https://bugs.ruby-lang.org/issues/12947#change-61521 * Author: Josh Cheek * Status: Closed * Priority: Normal * Assignee: * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15] * Backport: 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED ---------------------------------------- For an inline if statement, a numerical range literal in a conditional behaves like flip flop matching against `$.` Parsed [here](https://github.com/ruby/ruby/blob/0fe793cf9d400fdcc1f904e59d39c9b030758f42/parse.y#L1229-L1237). ``` 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](https://github.com/ruby/ruby/blob/0fe793cf9d400fdcc1f904e59d39c9b030758f42/parse.y#L2802-L2813). ``` $ printf first\nsecond\nthird\nforth\nfifth\n | ruby -ne 'if 2..4; print; end' first second third forth fifth ``` -- https://bugs.ruby-lang.org/ Unsubscribe: