Created
April 11, 2013 21:41
-
-
Save xpepper/5367434 to your computer and use it in GitHub Desktop.
My solution to Dave Thomas' exercise in 6th lession
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
class Struct | |
@children = [] | |
def self.inherited(child) | |
@children << child | |
end | |
class << self | |
attr_accessor :children | |
end | |
end | |
Dave = Struct.new(:name, :surname) | |
Fred = Struct.new(:age) | |
puts Struct.children # => [Dave, Fred] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment