On Saturday 02 January 2010, Werner Laude wrote:
> def delete_product(product)
>    
>  item = @items.find {|item| item.product == product}
>  item.delete
> 
> 
> Aber irgendwie findet er den Teil des arrays nicht. Ist das delete
>  korrekt so?

Nein.

$ ri Array#delete

----------------------------------------------------------- Array#delete
     array.delete(obj)            -> obj or nil
     array.delete(obj) { block }  -> obj or nil
------------------------------------------------------------------------
     Deletes items from _self_ that are equal to _obj_. If the item is
     not found, returns +nil+. If the optional code block is given,
     returns the result of _block_ if the item is not found.

        a = [ "a", "b", "b", "b", "c" ]
        a.delete("b")                   #=> "b"
        a                               #=> ["a", "c"]
        a.delete("z")                   #=> nil
        a.delete("z") { "not found" }   #=> "not found"


Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/
_______________________________________________
rubyonrails-ug mailing list
rubyonrails-ug@headflash.com
http://mailman.headflash.com/listinfo/rubyonrails-ug

Antwort per Email an