Created
July 13, 2012 16:28
-
-
Save myronmarston/3105803 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for for_i in [1, 2, 3] | |
end | |
puts "Variable from for: #{for_i.inspect}" | |
[1, 2, 3].each do |each_i| | |
end | |
puts "Variable from each: #{each_i.inspect}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
➜ ruby --version | |
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0] | |
➜ ruby for_vs_each.rb | |
Variable from for: 3 | |
for_vs_each.rb:9:in `<main>': undefined local variable or method `each_i' for main:Object (NameError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment