From: Robert Klemme Date: 2013-07-06T19:08:05+09:00 Subject: Re: Implementing sort/sort! --047d7bdcace49d8e5a04e0d4fc02 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Jul 6, 2013 at 12:26 AM, wrote: > Am 05.07.2013 23:21, schrieb Robert Klemme: > > Duh. No, you're not missing anything here. The only defense I have for >> the other form I have is that it is independent of the return value of >> #meth! - if you think of String#gsub! for example then your short >> version will not work because sometimes that method will return nil. >> That's probably the reason I made my form a habit. :-) >> > > A very good point. The `self` in the bang method is probably not > too unlikely to be forgotten. > Or it is used to signal something (like with String#gsub!). For those pairs where the non bang method returns a copy and the bang method changes the current object you depend on the copy being returned from the non bang method as the copy is only known inside the method. Thanks for sharing! > You're welcome! Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --047d7bdcace49d8e5a04e0d4fc02 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Sat, Jul 6, 2013 at 12:26 AM, <sto.mar@web.de> wrot= e:
Am 05.07.2013 23:21, schrieb Robert Klemme:

Duh. =A0No, you're not missing anything here. =A0The only defense I hav= e for
the other form I have is that it is independent of the return value of
#meth! - if you think of String#gsub! for example then your short
version will not work because sometimes that method will return nil.
=A0 That's probably the reason I made my form a habit. :-)

A very good point. The `self` in the bang method is probably not
too unlikely to be forgotten.

Or it is = used to signal something (like with String#gsub!). =A0For those pairs where= the non bang method returns a copy and the bang method changes the current= object you depend on the copy being returned from the non bang method as t= he copy is only known inside the method.

Thanks for sharing!

You&#= 39;re welcome!

Kind regards

robert


--
remember.guy do |as, ofte= n| as.you_can - without end
http://blog.rubybestpractices.com/
--047d7bdcace49d8e5a04e0d4fc02--