Fr David Black:
# Method definitions always have their own local scope, so a, b, and
# string are strictly local to the method. Blocks pick up the scope
# that they're created in, and can also create variables that weren't
# already in that scope. Those variables disappear when the block
# exits; the ones that were there already survive:
#
# x = 1
# some_method { y = x + 1 } # same x; new y
# y # undefined; block's y didn't survive
# x # same x
Hi David,
How about parameter variables, will its scoping change/stay in ruby2 ?
Currently,
irb(main):011:0> x="testing"
=> "testing"
irb(main):012:0> 5.times{|x|}
=> 5
irb(main):013:0> x
=> 4
i'd prefer
x = "testing"
some_method { |x| y = x + 1 } # different x; overrides any x
x # => "testing", same x outside
just asking for ruby englightenment
kind regards -botp