Skip to content

Instantly share code, notes, and snippets.

@xpepper
Created April 11, 2013 21:41
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 xpepper/5367434 to your computer and use it in GitHub Desktop.
Save xpepper/5367434 to your computer and use it in GitHub Desktop.
My solution to Dave Thomas' exercise in 6th lession
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