From: Eric Hodel Date: 2006-06-28T04:58:28+09:00 Subject: Re: Core documentation patches On Jun 27, 2006, at 10:53 AM, Jacob Fugal wrote: > On 6/27/06, Eric Hodel wrote: >> Should this me mentioned? >> >> $ ruby -ve "'cat \'o 9 tails' =~ '\d'" >> ruby 1.8.5 (2006-06-27) [powerpc-darwin8.6.0] >> -e:1:in `=~': type mismatch: String given (TypeError) >> from -e:1 > > To head of those that might ask (since I was about to before sitting > down and thinking it through): > > The exception is raised specifically for Strings while other non-Regex > types just get order reversed Exactly, this will work: o = Object.new def o.=~(other) return true end 'foo' =~ o o =~ 'foo' > By the way, but Eric's suggestion here and the original patch from > Alex apply to the 1.8.4 branch as well as 1.8.5: I believe all of 1.8 raises TypeError on 'foo' =~ 'o' (but I'm too lazy to check). -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com