Skip to content

Instantly share code, notes, and snippets.

@erubboli
Created September 11, 2010 10:50
Show Gist options
  • Save erubboli/575085 to your computer and use it in GitHub Desktop.
Save erubboli/575085 to your computer and use it in GitHub Desktop.
module Leaf
# ..omitted code..
def total_leafs
1
end
end
module Composite
# .. omitted code..
def total_leafs
@children.inject(0) {|sum, child| sum + child.total_leafs }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment