-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Labels
Milestone
Description
I found that if I use parens around a set of block parameters, JRuby seems to be re-assigning the existing variable in the containing scope. MRI keeps the block parameter local to the block. This only has been an issue in practice if there is a defined variable with the block param's name, but thought it was worth bringing up.
Here's some minimal example code to show the differences in behavior between JRuby and MRI.
def foo(key) # no parens around block params
{ a: "b", c: "d" }.map { |key, value| [key, value] }
return key
end
def bar(key) # note the presence of parens around block params
{ a: "b", c: "d" }.map { |(key, value)| [key, value] }
return key
end
# Ruby (tested with 1.9.3-p484 and 2.2.0)
puts foo(:hello) # => :hello
puts bar(:hello) # => :hello
# JRuby (1.7.20)
puts foo(:hello) # => :hello
puts bar(:hello) # => :cReactions are currently unavailable