I am just learning Ruby. Trying to add items to products hash in a Store object and then add some of those items to a cart array. I can get the store object to be created with store = Store.new that has the products hash and cart array. But don’t know how to add products to the hash and then to the array. I am probably not even close, but here is what I have so far:
class Store
def initialize
@products = {"item1" => 2.5, "item2" => 3.89, "item3" => 4.65, "item4" => 3.0, "item5" => 6.5}
@cart = []
end
def add_to_cart( item, price )
@cart <<
end
def add_product( item, price )
@products <<
end
end
Any help would be appreciated. Thanks.
1 Answer