Skip to content

Instantly share code, notes, and snippets.

@matthewrudy
Created November 30, 2008 23:15
Show Gist options
  • Save matthewrudy/30550 to your computer and use it in GitHub Desktop.
Save matthewrudy/30550 to your computer and use it in GitHub Desktop.
def add(data, tree)
if tree.end_of_a_branch? && tree.ND?
tree << data # we add something to the tree
else
add(data, tree.branch1) # we recurse
add(data, tree.branch2)
end
return tree # we always return the tree
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment