overloading << operator

Discussion in 'Ruby' started by Carl Youngblood, Dec 19, 2003.

  1. How do I create a class that will allow me to pass a string, for
    example, to an instance of it using the << operator? Like this:

    #==================================
    class Logger
    include Singleton
    ....
    end
    $logger = Logger.instance
    ....
    $logger << "Here is a log message"
    #==================================

    Thanks,
    Carl
    Carl Youngblood, Dec 19, 2003
    #1
    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. John Smith
    Replies:
    2
    Views:
    420
    Ivan Vecerina
    Oct 6, 2004
  2. Replies:
    11
    Views:
    729
    James Kanze
    May 16, 2007
  3. hurcan solter
    Replies:
    3
    Views:
    730
    Cholo Lennon
    Aug 29, 2007
  4. Replies:
    11
    Views:
    559
  5. Replies:
    2
    Views:
    312
Loading...

Share This Page