Created
September 11, 2010 10:50
-
-
Save erubboli/575085 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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