--00235429d75cf103ef04b8ea64a2
Content-Type: text/plain; charset=UTF-8

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

>
> Issue #6020 has been updated by Alex N.
>
>
> in
> 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  2
 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

--00235429d75cf103ef04b8ea64a2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div class="gmail_quote">On Tue, Feb 14, 2012 at 11:41 AM, Alex N <span dir="ltr">&lt;masterlambaster / gmail.com&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Issue #6020 has been updated by Alex N.<br>
<br>
<br>
=begin<br>
well, at least (({Integer.is_a?(Integer) #=&gt; true})).</blockquote><div><br><br>TL;DR : use `is_a?` on an _object_ of the class, not on the class itself.<br><br>Long version:<br><br>The confusion is that is_a? checks if the _object_ is of class Integer,<br>
not the Integer _class_.<br><br>So.<br><br>$ irb<br>1.9.3p0 :001 &gt; i =2<br>&gt; 12 <br>1.9.3p0 :002 &gt; i.class<br>=&gt; Fixnum <br><br>i is an _object_ of the Fixnum class.<br><br>1.9.3p0 :003 &gt; i.is_a?(Integer)<br>
=&gt; true <br><br>yes, the _object_ i is an Integer ...<br><br>1.9.3p0 :004 &gt; i.is_a?(Fixnum)<br>=&gt; true <br><br>... and also aixnum<br><br>1.9.3p0 :005 &gt; Integer.class<br>=&gt; Class <br>1.9.3p0 :006 &gt; Integer.is_a?(Integer)<br>
=&gt; false <br><br>but the _class_ Integer is not an Integer<br>(because Class does not inherit from Integer).<br><br>1.9.3p0 :007 &gt; Class.ancestors<br>=&gt; [Class, Module, Object, Wirble::Shortcuts, PP::ObjectMixin, Kernel, BasicObject] <br>
<br>Class only inherits from Module, Object and BasicObject and mixes in some<br>additional functionality.<br><br>HTH,<br><br>Peter<br clear="all"></div></div><br><br>-- <br>*** Available for a new project ***<br>
<br>Peter Vandenabeele<br>
<a href="http://twitter.com/peter_v" target="_blank">http://twitter.com/peter_v</a><div><a href="http://rails.vandenabeele.com/" target="_blank">http://rails.vandenabeele.com</a></div><a href="http://coderwall.com/peter_v" target="_blank">http://coderwall.com/peter_v</a><br>


--00235429d75cf103ef04b8ea64a2--