From: Ian Macdonald Date: 2003-07-04T19:47:00+09:00 Subject: Re: purpose of replace method On Fri 04 Jul 2003 at 19:35:21 +0900, Kent Dahl wrote: > For String#replace, this means that you can change a text you have > spread to several places without doing a reassignment again. This can be > handy if you have it a zillion places. (I.e. consider _one_ replace > versus N assignments.) Ah, I see. So: irb(main):001:0> foo = bar = "string" => "string" irb(main):002:0> foo = "new" => "new" irb(main):003:0> bar => "string" irb(main):004:0> foo = bar = "string" => "string" irb(main):005:0> foo.replace("new") => "new" irb(main):006:0> bar => "new" OK, that makes sense. replace is useful when multiple pointers point to the same object. Ian -- Ian Macdonald | Never try to keep up with the Joneses; they System Administrator | might be newlyweds. ian@caliban.org | http://www.caliban.org | |