From: "David A. Black" Date: 2004-12-09T04:51:21+09:00 Subject: Re: Overloading a module method? Hi -- On Thu, 9 Dec 2004, Dominik Werder wrote: > I'm having a headache while trying to achive something like this: > > module Math > def Math.cos val > if val.kind_of? MyType > val = super(val) > # do stuff with val and return > return val > else > # normal behavior > super > end > end > end > > super seems not to work, perhaps because Math is not a module.. > > Does anybody please know how to to this? I think what you want is to alias the old method. super takes you up the method lookup chain, whereas alias operates at the same level but moves laterally, so to speak. class << Math # operate on Math's singleton superclass alias :oldcos :cos def cos(val) # here, oldcos(val) will call the old cos etc. David -- David A. Black dblack@wobblini.net