------art_27904_19542152.1194554994083
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Nov 8, 2007 3:27 PM, 7stud -- <bbxx789_05ss / yahoo.com> wrote:

> How come when you redefine the inherited method in Class, you don't use
> the 'class method' syntax?  This doesn't work:
>
> class Class
>  def Class.inherited(class_obj)
>    puts class_obj
>    puts
>  end
> end
>
>
> Instead, you have to write:
>
> class Class
>  def inherited(class_obj)
>    puts class_obj
>    puts
>
>  end
> end
>
> Yet, in pickaxe2 on p. 445, the book lists inherited as a class method
> of Class.  And, if I have a class like this:
>
>
> class Dog
>  def Dog.speak
>    puts 'Woof'
>  end
> end
>
> Dog.speak
> -->Woof
>
>
> and I want to redefine Dog.speak, I have to do this:
>
> class Dog
>  def Dog.speak
>    puts 'yap yap'
>  end
> end
>
> Dog.speak
> -->yap yap
> --
> Posted via http://www.ruby-forum.com/.
>
>
I would guess it's because inheritance and everything related to it is
defined at object instantiation, not at Class definition. I would believe
that the Ruby VM doesn't care about class heirarchy until an object is
built, then it needs to look around to find out what's available to this new
object and what's not. You can do

class Class
   def Class.some_method
   end
end

just fine, but this isn't the problem you're seeing. You're seeing a problem
as to when a certain method is called.

Though please someone correct me if what I've said is wrong, this is just
educated guessing.

Jason

------art_27904_19542152.1194554994083--