On Tue, Feb 14, 2012 at 11:41 AM, Alex N <masterlambaster / gmail.com> wrote:

>
> Issue #6020 has been updated by Alex N.
>
>
> =begin
> well, at least (({Integer.is_a?(Integer) #=> true})).



TL;DR : use `is_a?` on an _object_ of the class, not on the class itself.

Long version:

The confusion is that is_a? checks if the _object_ is of class Integer,
not the Integer _class_.

So.

$ irb
1.9.3p0 :001 > i = 12
 => 12
1.9.3p0 :002 > i.class
 => Fixnum

i is an _object_ of the Fixnum class.

1.9.3p0 :003 > i.is_a?(Integer)
 => true

yes, the _object_ i is an Integer ...

1.9.3p0 :004 > i.is_a?(Fixnum)
 => true

... and also a Fixnum

1.9.3p0 :005 > Integer.class
 => Class
1.9.3p0 :006 > Integer.is_a?(Integer)
 => false

but the _class_ Integer is not an Integer
(because Class does not inherit from Integer).

1.9.3p0 :007 > Class.ancestors
 => [Class, Module, Object, Wirble::Shortcuts, PP::ObjectMixin, Kernel,
BasicObject]

Class only inherits from Module, Object and BasicObject and mixes in some
additional functionality.

HTH,

Peter


-- 
*** Available for a new project ***

Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com
http://coderwall.com/peter_v