# Re: How to find out object type

**URL:** <https://www.ruby-forum.com/t/re-how-to-find-out-object-type/86149>\
**Category:** Ruby\
**Created:** [February 20, 2007, 6:35am UTC](https://www.ruby-forum.com/t/re-how-to-find-out-object-type/86149 "2007-02-20T06:35:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phy\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@Phy\_P](https://www.ruby-forum.com/u/Phy_P)\
**Post date:** [February 20, 2007, 6:35am UTC](https://www.ruby-forum.com/t/re-how-to-find-out-object-type/86149/1 "2007-02-20T06:35:34Z")

</div>

Got it. thanks!

----- Original Message ----  
From: Harold H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: ruby-talk ML [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Monday, February 19, 2007 9:09:47 PM  
Subject: Re: How to find out object type

On 2/20/07, Phy P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> irb(main):006:0\>
> 
> I 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 does not work. Any help?

irb(main):001:0\> o = 42  
=\> 42  
irb(main):002:0\> the\_o\_array = [o]  
=\> [42]  
irb(main):003:0\> the\_o\_array.class  
=\> Array

hth,  
-Harold

---

<div class="post-metadata">

**Author:** ![Phy\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a587f6/32.png) [@Phy\_P](https://www.ruby-forum.com/u/Phy_P)\
**Post date:** [February 20, 2007, 2:06pm UTC](https://www.ruby-forum.com/t/re-how-to-find-out-object-type/86149/2 "2007-02-20T14:06:30Z")

</div>

On 2/20/07, Phy P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Got it. thanks!

I’m not sure you do.

> On 2/20/07, Phy P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ah, thats better. So now for the real nubie question, I am lost as to why this does not work:
> > 
> > irb(main):001:0\> o = 123  
> > =\> 123  
> > irb(main):002:0\> #{o} = Array.new

This won’t work. The “#{o}” notation only works in string  
interpolation. Outside of strings (and string-like constructors like  
Regexp literal notations), # acts as a comment. So both of your  
examples were no-ops. Your understanding of Ruby’s syntax and  
philosophy bit you here.

I think that you need to look around for comments about “duck typing”;  
I’d look very closely at some of the tutorials available on the web  
before you go much further.

-austin
