How does one determine an objects class?


#1

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?


#2

On Feb 1, 2006, at 10:13 AM, John M. wrote:

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?

str.class

Hope that helps.

James Edward G. II


#3

On 01/02/06, John M. removed_email_address@domain.invalid wrote:

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?

Which object?

-austin


#4

John M. wrote:

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?

puts str.class


#5

John M. wrote:

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?

str is of class String.

robert

:wink:


#6

Thanks chaps! I must say that I am impressed with the speedy reply:)

On


#7

John M. wrote:

Say I’ve got
str = IO.read(“testfile_for_using_file_open”)
how can Idetermone what class this object belongs to?

John, you can use the Object#class method.
In your case:

str.class

Use “ri class” for more info.

Cheers,
Antonio