From: Daniel Brumbaugh Keeney Date: 2008-03-09T09:00:29+09:00 Subject: Re: A question on singleton methods On Sat, Mar 8, 2008 at 5:47 PM, Arlen Cuss wrote: > On Sun, Mar 9, 2008 at 10:34 AM, mike leonard wrote: > > > def a_hash.fetch(:a).to_s > > "ALPHA" > > end Congratulations Sean O'Halpin, you beat me to send button. > By the by, I'm not sure redefining a String's #to_s will have any effect. It > sounds strange - perhaps you're better off building a class for those > objects and defining to_s on that? I have no idea what the possible purpose of redefining String#to_s is. However, I think this brings to mind an interesting idea. As part of Ruby's duck typing initiative, many methods call to_str on objects they expect to be strings. Having String#to_str return something other than self could produce some extremely confusing results. Daniel Brumbaugh Keeney