Hi --

On Tue, 4 Dec 2007, MonkeeSage wrote:

> On Dec 4, 5:23 am, MonkeeSage <MonkeeS... / gmail.com> wrote:
>> On Dec 4, 3:02 am, "David A. Black" <dbl... / rubypal.com> wrote:
>>
>>> They inherently change their receivers, but that's a separate matter
>>> from the !.
>>
>> Well...99% of the time it is, except when the ! only serves to
>> indicate that it operates in-place (String#reverse!, Hash#update!, and
>> probably a few others I can't think of offhand*). That's why I
>> characterized the ! as "either-or-both" regarding in-place/dangerous.
>> Even if it's not a good idea or breaks with the common usage, it is
>> used that way at least a few times in stdlib.
>>
>> * Oh yeah, and I just remembered #power! (on Bignum I think) which
>> isn't dangerous and doesn't modify the receiver...it just raises to a
>> power. Where the heck did the bang come from?!
>>
>> Regards,
>> Jordan
>
> Few more methods where the bang only indicates in-place operation:
>
> String#succ!, Array#reverse!, Array#collect!, Array#sort!

In-place modification is, I think, definitely the most common form of
!-style "danger". It's not the only form, though.


David

-- 
Upcoming training by David A. Black/Ruby Power and Light, LLC:
    * Intro to Rails, London, UK, December 3-6 (by Skills Matter)
See http://www.rubypal.com for details and 2008 announcements!