From: timr Date: 2010-11-12T04:35:26+09:00 Subject: Re: what's an object? On Nov 11, 12:59 am, Ammar Ali wrote: > On Thu, Nov 11, 2010 at 10:51 AM, Brian Candler wrote: > > One other point. A local variable is not an object and never is - > > I think that's too general and confusing, at least to me. > > >> def m > >>   a = [1,2,3] > >>   p a.is_a?(Object) > >>   end > => nil > >> m > > true > => true > > Is there more insight behind that statement? Or am I missing something > fundamental? > > Thanks, > Ammar When you ask object#is.a?(Class) you are asking if the Class is part of the ancestry of the object. So you ask an array if it inherits directly or indirectly from the Object class, and the answer is yes. Here is a demo: >> class New < String >> end => nil >> n = New.new => "" >> n.is_a? New => true >> n.is_a? String => true >> n.is_a? Array => false >> n.is_a? Object => true >> New.ancestors => [New, String, Enumerable, Comparable, Object, Kernel] But there is a distinction between inheriting from the Object class and being an object. A better demonstration that the object like the variable a points to in your example, is an instantiated object is to ask it if it has an object_id--and it will. So the answer agrees with the is_a? result, but the questions are asking very different things. Tim