From: Charles Oliver Nutter Date: 2007-07-17T15:03:16+09:00 Subject: Re: What are the semantics of to_str? Florian Gross wrote: > This is quite odd actually. MRI just does a respond_to?() on to_str > here. If that returns true it actually calls <=>. This is the same way > it handles == for all classes. (See > http://rubyforge.org/tracker/index.php?func=detail&aid=11585&group_id=426&atid=1698 > for a request to change the == semantics.) > > The thing to note here is that String#<=> doesn't use the same > semantics as Array#<=>: ... > I think this should be changed in MRI. Either all <=> methods should > use to_* as an indicator without actually calling it or they should > all call it. I'd prefer the last, because the indicator behaviour is > somewhat unusual. (I'd like to see it changed for == as well...) > > Is anyone from the MRI core team listening? Such are the joys of implementing Ruby. I think we've got it mostly right in JRuby, but it took a lot of tweaking. - Charlie