From: "kbloom@..." Date: 2006-11-26T09:20:07+09:00 Subject: Re: DictionaryMatcher (#103) Jamie Macey wrote: > On 11/24/06, Ruby Quiz wrote: > > # will automatically work as a result of implementing > > # DictionaryMatcher#=~ (see String#=~) > > "long string" =~ dm # => true > > On my machine (ruby 1.8.4), I don't get this result. For me, 'long > string' =~ /string/ returns the same as /string/ =~ 'long string', > which is 5, not true. > > Just a heads-up for anyone else using the provided code as the basis > for a test case. One of the unwritten rules of Ruby Quiz is to do whatever seems appropriate with the interface, given the real interface. You'll notice, for example, that a Regexp returns the offset from =~, a boolean from === (despite the documentation's claims to the contrary), and a MatchData object from #match. The alias_method part of the interface simplifies this aspect of the interface to DictionaryMatcher, although it defintiely makes more sense to invent a MatchData object of some sort that can tell you what the matched word was, and use that as the return value to match. --Ken