From: Rick DeNatale Date: 2008-02-29T07:41:36+09:00 Subject: Re: Named sprintf parameters On 2/28/08, yermej wrote: > On Feb 28, 11:29 am, ara howard wrote: > > > class String > > module M > > def % *args > > newstuff > > super > > end > > end > > include M > > end > > > > > Can you please explain this? It looks to me like it would allow you to > override a method, but still call the original without using alias. > However, when I try anything like that, it only calls the original > method. The method defined inside of M isn't called. Is that a 1.9 > thing or am I misunderstanding what you meant? No you are right. Including a module in a class effectively inserts the module above the class in the inheritance chain rather than below, a class can override methods in a module it includes, not the other way around. I missed Ara's point as well. Along these lines I was scratching my head the other night when I was reading Russ Olsen's "Design Patterns in Ruby" and he was showing an implementation of the Decorator pattern using modules as decorators, I missed the subtlety that he was using Object#extend to include a module above the singleton class of a particular object rather than including it in a 'real' class. But I don't think that technique applies here. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/