How does one determine an objects class?

Discussion in 'Ruby' started by John Maclean, Feb 1, 2006.

  1. John Maclean

    John Maclean Guest

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

    --
    John Maclean
    MSc (DIC)
    07739 171 531
     
    John Maclean, Feb 1, 2006
    #1
    1. Advertising

  2. On Feb 1, 2006, at 10:13 AM, John Maclean 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 Gray II
     
    James Edward Gray II, Feb 1, 2006
    #2
    1. Advertising

  3. On 01/02/06, John Maclean <> wrote:
    > Say I've got
    > str =3D IO.read("testfile_for_using_file_open")
    > how can Idetermone what class this object belongs to?


    Which object?

    -austin
    --
    Austin Ziegler *
    * Alternate:
     
    Austin Ziegler, Feb 1, 2006
    #3
  4. John Maclean

    Chris Gernon Guest

    John Maclean 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

    --
    Posted via http://www.ruby-forum.com/.
     
    Chris Gernon, Feb 1, 2006
    #4
  5. John Maclean 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






















    ;-)
     
    Robert Klemme, Feb 1, 2006
    #5
  6. John Maclean

    John Maclean Guest

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

    On
    Thu, 2 Feb 2006 01:13:56 +0900 John Maclean <> wrote:

    > Say I've got
    > str = IO.read("testfile_for_using_file_open")
    > how can Idetermone what class this object belongs to?
    >



    --
    John Maclean
    MSc (DIC)
    07739 171 531
     
    John Maclean, Feb 1, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. E11
    Replies:
    1
    Views:
    4,851
    Thomas Weidenfeller
    Oct 12, 2005
  2. 7stud
    Replies:
    11
    Views:
    717
    Dennis Lee Bieber
    Mar 20, 2007
  3. Peña, Botp
    Replies:
    1
    Views:
    246
    Robert Klemme
    Jan 24, 2004
  4. Steve Drach
    Replies:
    3
    Views:
    221
    Thomas E Enebo
    Jun 20, 2004
  5. stylechief
    Replies:
    10
    Views:
    175
    stylechief
    Dec 6, 2005
Loading...

Share This Page