From: Andrew Wagner Date: 2010-07-07T22:40:19+09:00 Subject: Re: New, but this seems odd... --0022154017fe4aec55048acc4fad Content-Type: text/plain; charset=UTF-8 That article is helpful, thanks. Somehow I had exactly that idea in my mind, that the ! implies side effects. I was expecting to get back a new array [1, 3], and that there would be a delete! method defined with the below behavior. That seems more consistent to me than some vague description that ! means "dangerous" for some value of "dangerous". I guess I still have plenty to learn. Thanks for the link! On Wed, Jul 7, 2010 at 9:25 AM, Rob Biedenharn wrote: > > On Jul 7, 2010, at 9:01 AM, Andrew Wagner wrote: > > Ok, granted that I'm pretty new to ruby, but this seems odd to me: >> >> irb(main):001:0> x = [1,2,3] >> => [1, 2, 3] >> irb(main):002:0> x.delete 2 >> => 2 >> irb(main):003:0> x >> => [1, 3] >> >> With this behavior, wouldn't "delete!" be a more appropriate name? >> > > > > Read > http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist > > Is there some kind of interpretation of "delete" that doesn't imply the > receiving object will be changed? > > Compare Hash#update and Hash#merge, for example. Hash#update changes the > receiving hash, which Hash#merge creates a new hash with extra/overwritten > keys from the argument hash. It shouldn't be too surprising that > Hash#merge! is an alias of Hash#update. > > -Rob > > Rob Biedenharn > Rob@AgileConsultingLLC.com http://AgileConsultingLLC.com/ > rab@GaslightSoftware.com http://GaslightSoftware.com/ > > > --0022154017fe4aec55048acc4fad--