From: Jonathan Rochkind Date: 2008-11-19T00:04:13+09:00 Subject: Re: let my custom defined class convert to string? Thanks, that helps a lot, actually! Jonathan Stefano Crocco wrote: > Alle Tuesday 18 November 2008, Jonathan Rochkind ha scritto: >> >> Is there anything I can do so my class will always be converted properly >> to a String by ruby, in all cases, so client code can really use it just >> like a string? >> >> Jonathan > > Defining a to_str method makes String#+ work, but I'm not sure it'll > work > everywhere. According to some documentation I found on google, defining > that > method should make the class usable in place of a string. Note, however, > that > you still have to define a to_s method if you want to change the output > of > puts. > > I hope this helps > > Stefano -- Posted via http://www.ruby-forum.com/.