From: "J. Cooper" Date: 2008-11-19T06:14:21+09:00 Subject: Re: let my custom defined class convert to string? Jonathan Rochkind wrote: > I wondered why #to_str and #to_s both existed, but my stack overflow > error seems to suggest that in some cases one is defined in terms of the > other. I still wonder why they both exist. The basic rule of thumb is that #to_s is for when we want something to have a form readable to us, and #to_str is for when we want something to have a string representation that allows it to be used in place of actual String arguments. Thus #print and #puts use #to_s, as they assume we want some readable output for humans, and most everything else that needs strings for arguments will try #to_str. Defining one doesn't define the other. -- Posted via http://www.ruby-forum.com/.