> class Cart
> attr_reader :items
>
> def initialize
> @items = []
> end
>
> def add_product(product)
> current_item = @items.find {|item| item.product == product}
> if current_item
> current_item.increment_quantity
> else
> @items << CartItem.new(product)
> end
> end
> end
>
> It seems to me that there is one too many "end"s here.
>
Looks okay to me. The first "end" closes the "if-else" block
The second "end" closes the "def" method
The third "end" closes the "class" declaration
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.