From: Jean-Hugues ROBERT Date: 2004-04-22T06:08:31+09:00 Subject: Re: Creating bang methods At 02:34 22/04/2004 +0900, you wrote: >On reflection, perhaps I have not been clear enough. I would like to create >bang methods of some math functions (mostly abs), but I don't know how to >modify the reciever in place because the value of self cannot be changed. >It's not really important that I be able to write these bang methods, but I >would very much like to understand how one would do it. > >Class Numeric > def abs! > ?? > end >end > >~Jon Hurst Some objects provide a .replace(): strings, hashes... I don't know about numerics but they look like immutable to me, so you may need a Facade delegating most of the work to the immutable object. I think there is a delegator.rb that may help, if delegate can be changed on the fly (I haven't checked) Jean-Hugues