Skip to content

Instantly share code, notes, and snippets.

@jfirebaugh
Created January 21, 2011 21:24
Show Gist options
  • Save jfirebaugh/790454 to your computer and use it in GitHub Desktop.
Save jfirebaugh/790454 to your computer and use it in GitHub Desktop.
1.8.7-p330
instance method: Foo::X
singleton method: ::X
class_eval: ::X
instance_eval: ::X
1.9.1-p378
instance method: Foo::X
singleton method: ::X
class_eval: Foo::X
instance_eval: Foo::X
1.9.2-p136
instance method: Foo::X
singleton method: Foo::X
class_eval: ::X
instance_eval: Foo::X
puts "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
X = '::X'
class Foo
X = 'Foo::X'
def foo
puts "instance method: #{X}"
end
end
Foo.new.foo
f = Foo.new
def f.bar
puts "singleton method: #{X}"
end
f.bar
Foo.class_eval do
puts "class_eval: #{X}"
end
Foo.new.instance_eval do
puts "instance_eval: #{X}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment