From: Mohammad Khan Date: 2004-11-13T04:35:28+09:00 Subject: Re: true? & false? On Fri, 2004-11-12 at 13:54, Michael DeHaan wrote: > "In ruby there have many methods that names end with '!' like, collect!, > compact!. I was so used to that '!' means its return the object after > 'affect' and without '!' return the part of the object that was > affected." > > The exclamation actually means the operation is destructive and > forever changes the contents of the calling object. It doesn't have > anything to do with the return codes. It's a very nice convention. > > Here is a good example: > http://www.rubycentral.com/book/ref_c_string.html#String.chomp > > In this case, both examples would return the same string, but one > would change the string it was called against. > Thanks for your nice explanation on exclamatory sign. And Sorry for my poor English. See the example below, I was confused with Array#delete! and Array#delete. Bottom line is, if there have something unfamiliar, I will have to learn it to make it familiar. There is no other way around. [mkhan@localhost bin]$ irb irb(main):001:0> arr = [1, 2, 2, 2, 3, 4] => [1, 2, 2, 2, 3, 4] irb(main):002:0> str = "string" => "string" irb(main):004:0> p arr [1, 2, 2, 2, 3, 4] => nil irb(main):005:0> p str "string" => nil irb(main):006:0> arr.delete(2) => 2 irb(main):008:0> str.delete("r") => "sting" irb(main):009:0> p arr [1, 3, 4] => nil irb(main):010:0> p str "string" => nil irb(main):011:0> str.delete!("r") => "sting" irb(main):012:0> arr.delete!(2) NoMethodError: undefined method `delete!' for [1, 3, 4]:Array from (irb):12 irb(main):013:0> p str "sting" => nil irb(main):014:0> p arr [1, 3, 4] => nil irb(main):015:0> Mohammad -- [mkhan@localhost local]$ make love make: *** No rule to make target `love'. Stop.