Skip to content

Instantly share code, notes, and snippets.

@shadeslayer
Created April 4, 2015 20:58
Show Gist options
  • Select an option

  • Save shadeslayer/92d099fd4ed526002565 to your computer and use it in GitHub Desktop.

Select an option

Save shadeslayer/92d099fd4ed526002565 to your computer and use it in GitHub Desktop.
class Node
include Enumerable
property :left, :right, :data
def initialize(data)
@data = data
end
def each(&block)
left.each(&block) if left
block.call(self)
right.each(&block) if right
end
def <=>(other)
@data <=> other.data
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment