Created
July 31, 2012 00:55
-
-
Save brianstorti/3212372 to your computer and use it in GitHub Desktop.
Flattening the scope
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
my_var = 0 | |
class MyClass | |
# we want to print my_var here | |
def my_method | |
# and here | |
end | |
end | |
#### | |
my_var = "win" | |
MyClass = Class.new do | |
puts "#{my_var} in the class definition" | |
define_method :my_method do | |
puts "#{my_var} in the method definition" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment