Skip to content

Instantly share code, notes, and snippets.

@tyler-smith
Created October 4, 2012 23:29
Show Gist options
  • Save tyler-smith/3837116 to your computer and use it in GitHub Desktop.
Save tyler-smith/3837116 to your computer and use it in GitHub Desktop.
class Object
def x
"Object's x"
end
end
class MyClass
x = "hello"
end
def foo
Object.new.instance_eval {puts x}
end
def bar
def x; "Boom!"; end
x = "Hello!"
Object.new.instance_eval {puts x}
end
foo #=> Object's x
bar #=> Hello!
puts MyClass.x #=> Boom!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment