From: Phy Prabab Date: 2007-02-20T14:01:15+09:00 Subject: Re: How to find out object type --0-31303925-1171947670=:58177 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable ah, thats better. So now for the real nubie question, I am lost as to why = this does not work:=0A=0Airb(main):001:0> o =3D 123=0A=3D> 123=0Airb(main):= 002:0> #{o} =3D Array.new=0Airb(main):003:0* o.class=0A=3D> Fixnum=0Airb(ma= in):004:0> #{o}.class=0Airb(main):005:0* =0Airb(main):006:0* ^C=0Airb(main)= :006:0>=0A=0AI was hoping to be create an array from the numb stored as "o"= , but this must be wrong, because trying to get the class of the object doe= s not work. Any help?=0A=0A----- Original Message ----=0AFrom: Gary Wright= =0ATo: ruby-talk ML =0ASent: Mon= day, February 19, 2007 8:51:18 PM=0ASubject: Re: How to find out object typ= e=0A=0A=0AOn Feb 19, 2007, at 11:38 PM, Phy Prabab wrote:=0A> I am curious,= is there a way to find out an object type?=0A=0AYou can find out what clas= s gave 'birth' to the object via #class:=0A=0A[1,2].class # Array=0A3.cla= ss # Fixnum=0A=0ANote that #class does *not* return a string (e.g., "= Array") but instead=0Areturns a reference to the actual class object:=0A=0A= a =3D [1,2].class.new # allocates a brand new array=0Ap a = # []=0A=0AIt is important to realize that the 'class' of an object is reall= y just=0Aa hint at how an object will respond to methods. It might be a re= ally=0Agood hint, but a hint nevertheless since objects are free to overrid= e=0Amethod definitions provided by the class or even to add methods that=0A= the class doesn't provide:=0A=0Ab =3D [10,20,30]=0Adef b.penultimate=0A s= elf[-2]=0Aend=0Ab.penultimate # 20=0A=0A=0A=0AGary Wright=0A=0A=0A=0A=0A= =0A=0A=0A=0A=0A=0A=0A =0A__________________________________________________= __________________________________=0AThe fish are biting. =0AGet more visit= ors on your site using Yahoo! Search Marketing.=0Ahttp://searchmarketing.ya= hoo.com/arp/sponsoredsearch_v2.php --0-31303925-1171947670=:58177--