Skip to content

Instantly share code, notes, and snippets.

@amatsuda
Last active August 29, 2015 14:25
Show Gist options
  • Save amatsuda/469302f6440ac9fa4ae3 to your computer and use it in GitHub Desktop.
Save amatsuda/469302f6440ac9fa4ae3 to your computer and use it in GitHub Desktop.
I do understand what's happening, but...
if false
a = 2
p a
else
Proc.new do |a|
p a
end
end
if true
Proc.new do |a|
p a
end
else
a = 2
p a
end
% ruby -w shadowing_outer_local_variable.rb
shadowing_outer_local_variable.rb:5: warning: shadowing outer local variable - a
% ruby -w not_shadowing_outer_local_variable.rb
(No warning!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment