From: Robert Dober Date: 2006-03-30T01:26:25+09:00 Subject: Re: Regexp gotcha ------=_Part_1897_11014800.1143649582180 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 3/29/06, Pistos Christou wrote: > > FWIW, we still have the same problem: > > irb(main):255:0> r1 =3D~ s > =3D> 0 > irb(main):256:0> r2 =3D~ s > =3D> nil > irb(main):257:0> r3 =3D~ s > =3D> false > > I've taken note that you say that r =3D~ s is faster. I (or someone else= ) > will have to do some benchmarking to see whether that's really true, and > how much speed gain can be had. Diakonos suffers when you use large and > many regexps for syntax highlighting, so I'd be interested in anything > that can speed that up. > > Pistos > > -- > Posted via http://www.ruby-forum.com/. > > Pistos I do not want to enter into the discussion if it should be like that or not= . The beauty of ruby is that you can change a lot of things if you do not lik= e them. In your case, maybe you like the following ---------------------------------------------------------------- class String alias_method :__old_match, :=3D~ def =3D~(obj) raise RuntimeError, "#{obj.nil? ? "nil" : obj.to_s} is not a Regexp but #{ obj.class}" unless Regexp =3D=3D=3D obj __old_match obj end # def =3D~(obj) end # class String puts "x" =3D~ %r{.} puts "x" =3D~ nil ------------------------------ Hope this is helpfull Cheers Robert -- Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_1897_11014800.1143649582180--