Skip to content

Instantly share code, notes, and snippets.

@polotek
Created May 11, 2012 23:45
Show Gist options
  • Save polotek/2663147 to your computer and use it in GitHub Desktop.
Save polotek/2663147 to your computer and use it in GitHub Desktop.
def foo
bar = "bar"
arr = [1, 2, 3]
arr.map {|a|
fizz = "buzz" + a.to_s
# this line is fine, blocks can access the enclosing scope
print bar + "\n"
}
# this throws, fizz is only defined within the local block
print fizz
end
foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment