D
Dominic Son
Hi. I'm confused as to why this variable* is nessesary:
-----------
def add_product(product)
existing_product = @items.find {|item| item.product == product}
if existing_product
existing_product.increment_quantity
else
existing_product = CartItem.new(product)
@items << existing_product
end
existing_product*
end
--------------
i'm a newb, and to a newb, i can't understand why a var just sits there.
can someone please explain what the purpose of exisiting_product* is?
i'd figure exisiting_product* wouldn't be needed since on the 2nd line,
existing_product is initialized with @items.find..blahblahblah..
-----------
def add_product(product)
existing_product = @items.find {|item| item.product == product}
if existing_product
existing_product.increment_quantity
else
existing_product = CartItem.new(product)
@items << existing_product
end
existing_product*
end
--------------
i'm a newb, and to a newb, i can't understand why a var just sits there.
can someone please explain what the purpose of exisiting_product* is?
i'd figure exisiting_product* wouldn't be needed since on the 2nd line,
existing_product is initialized with @items.find..blahblahblah..