From: Robert Klemme Date: 2004-10-18T21:44:22+09:00 Subject: Re: [Chocolate Ketchup Dressing] A working Ruby source code filter "Edgardo Hames" schrieb im Newsbeitrag news:478c16ae041018053737c72bec@mail.gmail.com... > On Sat, 16 Oct 2004 09:34:28 +0900, Florian Gross wrote: > > Moin! > > > > I've implemented a Ruby source code filter for the frequently requested > > ".=" operator. (Replace by result of method call) > > > > Here's a boring example of how it is used: > > > > #!/usr/bin/ruby -rfilter > > obj = "foobar" > > obj .= reverse > > p obj # => "raboof" > > Hi, Florian. How does .= differ from bang methods? > I mean obj.reverse seems to be the same as obj.reverse! Not quite: the bang method usually saves an intermediate instance *and* it might have undesirable side effects (if someone else holds a reference to the instance and doesn't expect it to be modified). As a consequence, ".=" will work with frozen objects, while bang methods usually don't. As usual it's a tradeoff / design decision which of both approaches you use. Kind regards robert