Skip to content

Instantly share code, notes, and snippets.

Created July 29, 2014 16:16
Show Gist options
  • Save anonymous/28e2323b33b8e589457c to your computer and use it in GitHub Desktop.
Save anonymous/28e2323b33b8e589457c to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
module M
refine NilClass do # !> Refinements are experimental, and the behavior may change in future versions of Ruby!
def magic
"some magic stuff is happening"
end
end
end
class Hohooo
end
howdy = Hohooo.new # => #<Hohooo:0x007fc55210c4c0>
howdy.instance_eval("using M\nnil.magic") # =>
# ~> -:18:in `instance_eval': undefined method `using' for #<Hohooo:0x007f98ac21c4f0> (NoMethodError)
# ~> from -:18:in `instance_eval'
# ~> from -:18:in `<main>'
eval("using M\nnil.magic") # => "some magic stuff is happening"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment