From: "Peña, Botp" Date: 2008-06-28T16:46:34+09:00 Subject: Re: Determining lists,strings and numbers(Newbie question) From: vimal [mailto:cool.vimalsmail@gmail.com] # How can one determine whether a given object is a list or string or # number botp@botp-desktop:~$ qri object.is_a? ----------------------------------------------------------- Object#is_a? obj.is_a?(class) => true or false obj.kind_of?(class) => true or false ------------------------------------------------------------------------ Returns true if class is the class of obj, or if class is one of the superclasses of obj or modules included in obj. module M; end class A include M end class B < A; end class C < B; end b = B.new b.instance_of? A #=> false b.instance_of? B #=> true b.instance_of? C #=> false b.instance_of? M #=> false b.kind_of? A #=> true b.kind_of? B #=> true b.kind_of? C #=> false b.kind_of? M #=> true irb(main):001:0> "asdf".is_a? String => true irb(main):002:0> "asdf".is_a? Integer => false irb(main):003:0> 1.is_a? Integer => true irb(main):004:0> 1.is_a? Array => false irb(main):005:0> ["",1].is_a? Array => true