Forum: Ruby Re: How to find out object type

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Phy P. (Guest)
on 2007-02-20 07:34
(Received via mailing list)
Ah, that's the ticket!  Great thanks for the explanation!

----- Original Message ----
From: Gary W. <removed_email_address@domain.invalid>
To: ruby-talk ML <removed_email_address@domain.invalid>
Sent: Monday, February 19, 2007 9:11:45 PM
Subject: Re: How to find out object type

On Feb 20, 2007, at 12:01 AM, Phy P. 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} =
> irb(main):003:0* o.class
> => Fixnum
> irb(main):004:0> #{o}.class

The #{} notation is only applicable inside a string:  "#{o}".  The
way you are using it make the line look like a comment.
Everything after the # is simply discarded.

Maybe you are looking for something like:

a = 123
b = [o]
p b        # [123]

Gary W.
This topic is locked and can not be replied to.