On Feb 1, 2006, at 8:28 PM, James Herdman wrote: > First of all, thanks to everyone who's replied so far. I > appreciate the help and insight. > > I think I'm getting the grip of things. > >>>> "".kind_of? Object >> => true > #kind_of? tests if an object is an instance of the given class. "" is an instance of String, which means its also an instance of Object. > This confused me a bit. "" is an instance of String, right? I > know String is an instance of Object, but that doesn't really make > "" an Object... or does it? > You are right, that doesn't make it an object. What does make it an Object is that the class String inherits from the class Object. This means anywhere you can use an instance of Object, you can use an instance of String. Therefore, "" is indeed a kind_of Object > Another thing that confused me is this: > > String.kind_of? String > => false > String is not an instance of String, or of any of String's descendants > At first I thought that perhaps an object can't be an instance of > itself as it, itself, is defining said object (i.e. it is a Class > -- the blueprint). However, > > Object.kind_of? Object > => true > Just remember, in Ruby, everything is an object. (Everything that can receive messages anyway.) So of course Object is an Object. > and > > Module.kind_of? Module > => true > Yeah this one is weird. (Well so was the last one) Module is actually the base class of Class. Modules are sort of like classes, but you can't inherit from them. Anyway any class is a kind_of Class and by extension a kind_of Module. Any module is also a kind_of Module. Module happens to be an instance of Class. Therefore Module.kind_of? Module is true. kind_of could be defined as follows: a.kind_of? B is true if B.ancestors.include?(a.class) > What am I missing? > > James H > >