Jeff Schwab
8/20/2006 3:01:00 PM
Paul Lutus wrote:
> Hal Fulton wrote:
>
>> Paul Lutus wrote:
>>> Nicolas Benady wrote:
>>>
>>>
>>>> Hello,
>>>> I have an array, let's name it items[]
>>>> I want to remove an object in a elegant way
>>>> items.remove(3) does not work
>>>> How should I do ?
>>>> Thanks
>>>>
>>>
>>> items.delete_at(3)
>>>
>>> Just like in the documentation.
>>>
>> Did he want to remove the element at index 3,
>> or remove instances of 3?
>
> I suppose I should have asked that before replying. :)
>
> If your theory is correct, then:
>
> items.delete_if { |x| x == 3 }
>
> Removes all items matching "3".
items.delete(3)