[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: [Q] Array.delete
From:       Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date:       2004-01-14 15:07:45
Message-ID: 40055BD8.90405 () wanadoo ! fr
[Download RAW message or body]

E.-R. Bruecklmeier wrote:

> Is there a method similar to Array.delete which returns the modified 
> array instead of modifing the array by itself?
>
> Why aren's there two methods:
>
> Array.delete
>
> and
>
> Array.delete!
>
> ???

if Array.delete was duplicating the array before removing the value, it 
would be a huge performance killer for big arrays.
you can simply do:
oldArray = myArray.dup
myArray.delete(obj)

emmanuel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic