From: dblack@... Date: 2006-12-06T21:24:18+09:00 Subject: Re: Unexpected scope range On Wed, 6 Dec 2006, Paul Lutus wrote: > IMHO, classes _have_ instances, but classes are not themselves instances. No, that's wrong. Classes are unambiguously and unequivocally instances of the class Class. The "classes are objects too" principle is very, very important in Ruby. Lots of things happen that are impossible to understand without understanding that principle. As for instance variables: each and every instance variable belongs to a particular object, and every object is an instance of some class. class C @x = 1 # an instance variable of the object C, which is # an instance of Class def meth @x = 1 # an instance variable of any instance of C that end # calls this method end The ownership of instance variables is governed by what object is playing the role of "self" at the point when the instance variable is encountered. The object may, indifferently, be an instance of Class, an instance of String, an instance of MyClass, and so on. The term "class instance variable" is completely inappropriate, and potentially very confusing, as a synonym for "instance variable". David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org