Skip to content

Instantly share code, notes, and snippets.

@mynyml
Created December 5, 2009 11:00
Show Gist options
  • Save mynyml/249646 to your computer and use it in GitHub Desktop.
Save mynyml/249646 to your computer and use it in GitHub Desktop.
class Context
end
Context.new.instance_eval <<-END
class String
def foo() 'foo' end
end
puts ''.foo
END
#=> undefined method `foo' for "":String (NoMethodError)
-----
class Context
end
Context.new.instance_eval do
class String
def foo() 'foo' end
end
puts ''.foo
end
#=> foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment