Skip to content

Instantly share code, notes, and snippets.

@richo
Created November 19, 2012 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richo/4109520 to your computer and use it in GitHub Desktop.
Save richo/4109520 to your computer and use it in GitHub Desktop.
col = [1, 2, 3]
some_value = 0
col.each do |i|
val = "thing"
some_value = i
end
begin
puts val
rescue NameError
# val not defined in this scope
end
puts some_value
for i in col
val = "thing"
some_value = i
end
puts val
puts some_value
@richo
Copy link
Author

richo commented Nov 19, 2012

outputs:

3
thing
3

Try removing the begin..rescue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment