From: "RubyTalk@..." Date: 2008-08-30T01:46:10+09:00 Subject: Re: Class === On Thu, Aug 28, 2008 at 5:53 PM, David A. Black wrote: > [I seem to have added the letter 'B' to the subject line when I > replied, so I'm replying again without doing so.] > > Hi -- > > On Fri, 29 Aug 2008, RubyTalk@gmail.com wrote: > >> I need help with === and Objects >> >> 270 Array === Array >>> >>> ] false [< >> >> 290 Array == Array >>> >>> ] true [< >> >> 300 Object === Object >>> >>> ] true [< >> >> 310 Object.class >>> >>> ] Class [< >> >> 320 Object === Class >>> >>> ] true [< >> >> >> I would think that Array === Array. If not I would not expect line 300 >> to be true. > > Those are two very different cases, though. Given this: > > a === b > > it is true if the class of b has a in its ancestry. So you can always > try: > > b.class.ancestors.include?(a) > > If you plug Object/Object into that expression, you'll get true. If > you plug Array/Array in, you won't. The reason is that all objects are > instances of Object and its descendants, including the class object > Object. So Object has a unique relationship, among classes, to itself. > > > David > > -- > Rails training from David A. Black and Ruby Power and Light: > Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL > Advancing with Rails January 19-22 Fort Lauderdale, FL > See http://www.rubypal.com for details and updates! > > I guess the thing i still struggle with is these lines: The reason is that all objects are instances of Object and its descendants, including the class object Object. So Object has a unique relationship, among classes, to itself. Mostly the " the class object Object" Is there a visual representation of this? It might help me understand.. Thanks Becker