Created
November 29, 2015 19:22
-
-
Save mehlah/c61964ec34a272c36af9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Human | |
def hello | |
p 'Hello' | |
end | |
end | |
class Cat | |
include Human | |
def mew | |
p 'moeeew' | |
end | |
end | |
class Dog | |
def bark | |
p 'waaaaf' | |
end | |
define_method :hello, Human.instance_method(:hello) | |
#define_method :hello, Cat.instance_method(:hello) | |
end | |
Dog.new.hello | |
#=> 'Hello' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment