From: "Chr. Rippel" Date: 2002-01-31T07:44:43+09:00 Subject: Re: strange behavior "Paul Brannan" wrote in .... > IMO, a method should not have to know the name of the class in which it > is defined. If I change the name of the class, then I must be very > careful to make sure that I also change any code inside the class > definition that uses the original name. Additionally, if I > cut-and-paste a function from one class to another, then I must also be > careful. > > In theory, changing a class name isn't (or shouldn't) be done often, and > I should really consider why I am using cut-and-paste anyway instead of > designing my code properly in the first place. A wise person once > said, though, that the diffence between theory and real life is real > life. One problem is that at the ``time of method body declaration'' you don't have access to the context - a.k.a binding. It's a bit like the use of Pythons ``self'' variable - if don't spezify ``self'' you cannot access self (in Python) class A def A.meth; "a" end def foo(class_name = A) puts class_name.meth end end class B < A def B.meth; "b" end end b= B.new b.foo # => a b.foo(B) # => b /Christoph