R
Ruby Rabbit
I have a data model and would like to let it be Enumerable. I want to
confirm if this is the way of implementing each and <=> :
def each
@list.each { |item| yield item }
end
def <=>(other)
@list <=> other
end
(let's just assume that @list is an array)
Thanks.
confirm if this is the way of implementing each and <=> :
def each
@list.each { |item| yield item }
end
def <=>(other)
@list <=> other
end
(let's just assume that @list is an array)
Thanks.