From: Zach Dennis Date: 2003-11-27T04:02:07+09:00 Subject: Re: defining a 'puts' or a 'print' for a class Thanks Gavri! -----Original Message----- From: Gavri Savio Fernandez [mailto:Gavri_F@infosys.com] Sent: Wednesday, November 26, 2003 1:59 PM To: ruby-talk ML Subject: Re: defining a 'puts' or a 'print' for a class > -----Original Message----- > From: Zach Dennis [mailto:zdennis@mktec.com] > Subject: defining a 'puts' or a 'print' for a class > > e = Email.new( ...stuff here... ) > puts Email.print > > > > But 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 ___________________________________________ 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