From: dblack@... Date: 2002-12-23T15:41:30+09:00 Subject: Re: Calling super from some other method Hi -- On Mon, 23 Dec 2002, Matt Armstrong wrote: > Say I have: > > class A > def method > puts "A#method" > end > end > > class B < A > def method > other_method > end > def other_method > method # <- want A#method here > end > end > > In B#other_method, I want to call A#method. > > Within B#method, I can call A#method with super. But I can't figure > out how to do the same within B#other_method. In C++, I'd just > statically qualify the class name in the source (A::method), but I > don't know how to do this in Ruby. Hmmm.... This sounds like one of the things in the "Mommy, where do methods come from?" thread. If I'm right about that, here's a possibly relevant exchange between Chris Pine and Nobu: Chris: Finally (and I'm sure I should know this one already), how would I call Object#to_s on foo if I have already redefined to_s? (Is this even possible?) Nobu: Impossible outside redefined to_s, unless it's aliased. I think the general principle is that you can't just call A#method, in the abstract; you have to send the message to a specific object, and since you've redefined the method, the object in question does something else when you send it that message. David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav