[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

method versus method!

Fred Werne

10/14/2003 6:16:00 PM

Hi

Why isn't the name of the Array-method delete_at delete_at! ?

The method changes the object, doesn't it?

Fred from Wuppertal, Germany

2 Answers

daz

10/15/2003 4:18:00 AM

0


"Fred Werne" <fred_w@wtal.de> wrote:

> Hi
>
> Why isn't the name of the Array-method delete_at delete_at! ?
>
> The method changes the object, doesn't it?
>
> Fred from Wuppertal, Germany
>


There are others like this, too.

The naming-convention seems to be that a (! "bang") method exists
only if there is a corresponding (non-bang) method which doesn't
modify the receiver.


daz



Samuel Tesla

10/15/2003 4:20:00 AM

0

Fred Werne <fred_w@wtal.de> writes:

> Why isn't the name of the Array-method delete_at delete_at! ?
>
> The method changes the object, doesn't it?

I would venture a guess that it is because unlike #sort/#sort! and its
bretheren, there's really not a reason to have a version that returns
a copy with the deleted index instead of just deleting the index. So
why make delete_at! if there's not going to be delete_at?

That's my $0.02.

-- Samuel