Skip to content

Instantly share code, notes, and snippets.

@brianstorti
Created July 31, 2012 00:55
Show Gist options
  • Save brianstorti/3212372 to your computer and use it in GitHub Desktop.
Save brianstorti/3212372 to your computer and use it in GitHub Desktop.
Flattening the scope
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