From: "rosenfeld (Rodrigo Rosenfeld Rosas)" <rr.rosas@...>
Date: 2013-07-04T02:33:33+09:00
Subject: [ruby-core:55786] [ruby-trunk - Feature #8600] Recognize variables declared in if modifier at end of line


Issue #8600 has been updated by rosenfeld (Rodrigo Rosenfeld Rosas).


Or maybe because it would be too complex to change the parser to support that? Now I'm not sure about the reasons...
----------------------------------------
Feature #8600: Recognize variables declared in if modifier at end of line
https://bugs.ruby-lang.org/issues/8600#change-40280

Author: rudolph9 (Kurt Rudolph)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: next minor



(({2.0.0 (main):0 > .ruby -v
ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-darwin12.3.0]
2.0.0 (main):0 > ([0,1,2])[i] = 1.0 if i = ['seconds'].find_index('seconds')
NameError: undefined local variable or method `i' for main:Object
from (pry):1:in `__pry__'}))

Is it possible to get rid of this kind of error?  Especially since it doesn't matter what the value of the variable is so long as it's defined.

(({2.0.0 (main):0 > i = 10000
=> 10000
2.0.0 (main):0 > ([0,1,2])[i] = 1.0 if i = ['seconds'].find_index('seconds')
=> 1.0}))


-- 
http://bugs.ruby-lang.org/