From: Gavin Sinclair Date: 2003-01-14T09:39:53+09:00 Subject: Re: Array_Of(AClass) On Tuesday, January 14, 2003, 9:59:44 AM, dblack wrote: > Technique #2 is not a drop-in replacement for technique #1, though. > For example, if you want to "listen in" on what a method is doing, > you might do: > class String > alias :oldsplit :split > def split(*a) > puts "args are #{a.join(', ')}" > oldsplit(*a) > end > end > I don't think there's an equivalent way to do this by modifying the > object's singleton class. If it's just a single object, surely you can: class << the_str def split(*args) puts "args are #{args.join(', ')}" super end end Which, again, is much nicer than aliasing. However, it only works on one String instance, not all of them. Which was probably your point. Gavin