Last active
August 29, 2015 14:01
-
-
Save mathildathompson/4ac51f281754b130762e 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
def each(&block) | |
node = @head | |
while node | |
block.class(node.value) | |
end | |
end | |
#A minix a way of adding extra data to the class without having to use inheritance; | |
#You can only inherit from one class, a way to get around this is to created mixins; | |
module Mother | |
def eyes | |
:blue | |
end | |
end | |
module Father | |
def hair | |
:purple | |
end | |
end | |
class Son#You can only inherit from one things | |
include Mother | |
include Father | |
end | |
class Daughter < Father | |
end | |
module Insect | |
class Butterfly | |
end | |
end | |
Insect::Butterfly | |
ActiveRecord::Butterfly #This will group all of the Active Record classes together, it prevents conflicts very carefully; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment