Project

General

Profile

Actions

Bug #12947

closed

Multiline if statements behave differently than inline if statements for flip flop

Added by josh.cheek (Josh Cheek) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[ruby-core:78162]

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

Updated by josh.cheek (Josh Cheek) over 7 years ago

s/it behaves like a regex/it behaves like a range/

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Status changed from Open to Closed

Applied in changeset r56811.


test_flip.rb: r56316

Updated by nobu (Nobuyoshi Nakada) over 7 years ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0