From: Zach Dennis [mailto:zdennis@mktec.com]
Subject: defining a ‘puts’ or a ‘print’ for a class
e = Email.new( …stuff here… )
puts Email.printBut I would love to say:
puts Email
to get the same result.
if you actually meant
puts e
all you need to do is define the ‘to_s’ method to return the String you need to print
class Email
def to_s
“arbitary string”
end
end
puts e
Any ideas?
Thanks,
Zach
Gavri Savio Fernandez
···
-----Original Message-----
I can’t stand cheap people. It makes me real mad when someone says something like, “Hey, when are you going to pay me that $100 you owe me?” or “Do you have that $50 you borrowed?” Man, quit being so cheap! - Jack handy