Skip to content

Instantly share code, notes, and snippets.

@volh
Created June 23, 2010 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volh/450102 to your computer and use it in GitHub Desktop.
Save volh/450102 to your computer and use it in GitHub Desktop.
class A
def a
'a'
end
end
module M extend self
class A
def a
"evil is here!"
end
end
def m
A.new.a
end
end
module N extend self
include M
def n
A.new.a
end
end
> M.m
=> "evil is here!"
> N.n
=> "evil is here!"
> A.new.a
=> "a"
# Too bad it doesn't work for basic types, this way we could eliminate monkeypatching damage.
# Well, it could actually work, but you need to explicitly do String.new, Hash.new etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment