Personal
Join the DZone community and get the full member experience.
Join For Freeclass WishlistItem
attr_reader :price
FAKE_DATABASE = []
# def self.arr
# @pricearr = [29, 33, 30]# @pricearr
# end
def initialize(price)
@price = price
FAKE_DATABASE.unshift(self)
end
def self.find_recent
FAKE_DATABASE
end
def <=>(a)
self.price <=> a.price
end
# Populate initial items
new("$29")
new("$33")
new("$30")
end
p WishlistItem.find_recent.sort
Opinions expressed by DZone contributors are their own.
Comments