Skip to content

Instantly share code, notes, and snippets.

@taq
Created November 3, 2012 19:02
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 taq/4008290 to your computer and use it in GitHub Desktop.
Save taq/4008290 to your computer and use it in GitHub Desktop.
Module#prepend - using include on 1.9.x
class C
def x; "x"; end
end
module M
def x; '[' + super + ']'; end
def y; "y"; end
end
class C
include M
end
p C.ancestors # [C, M, Object, Kernel, BasicObject]
c = C.new
puts c.x # => x
puts c.y # => y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment