From: jake kaiden Date: 2011-08-26T22:31:52+09:00 Subject: Re: operator overloading ? jack jones wrote in post #1018639: > # why doesn't it work? your syntax is not quite ruby... maybe something like this is what you want? class Whatever attr_accessor :number, :str def initialize(number) @number = number @str = "Your number is : ( #{@number} )" end def >> puts @number puts @str end end object = Whatever.new(10) object.>> # returns: => 10 => Your number is : ( 10 ) note that you don't need to set :number and :str as atrr_accessors for this to work... if you want to leave them as accessors, you don't really need the '>>' method, you could do something like this instead: class Whatever attr_accessor :number, :str def initialize(number) @number = number @str = "Your number is : ( #{@number} )" end end object = Whatever.new(10) puts object.number puts object.str # also returns: => 10 => Your number is : ( 10 ) - j -- Posted via http://www.ruby-forum.com/.