programming-examples/ruby/Data_Structures/tree_node.rb

16 lines
242 B
Ruby
Raw Normal View History

2019-11-15 12:59:38 +01:00
class Node
attr_accessor :left, :right, :data
def initialize(data)
self.data = data
end
def to_s
"(Data: #{@data}) : (Left: #{@left&.data}) : (Right: #{@right&.data})"
end
def ==(other)
data == other.data
end
end