Skip to content

Instantly share code, notes, and snippets.

@fj
Created April 24, 2014 15:59
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 fj/11259853 to your computer and use it in GitHub Desktop.
Save fj/11259853 to your computer and use it in GitHub Desktop.
def outer(&b)
foo = 1
block.call
end
def inner(v)
puts foo + v
end
# Is there a way to make 'foo' available in the scope of `inner`?
outer {
inner 6 # want to print 7 (1 + 6)
inner 29 # want to print 30 (1 + 29)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment