Created
April 24, 2014 15:59
-
-
Save fj/11259853 to your computer and use it in GitHub Desktop.
This file contains 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
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