------art_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 <jesusrubsyou.5.pistos / geoshell.com> wrote:
>
> FWIW, we still have the same problem:
>
> irb(main):255:0> r1 =~ s
> => 0
> irb(main):256:0> r2 =~ s
> => nil
> irb(main):257:0> r3 =~ s
> => false
>
> I've taken note that you say that r =~ 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 like
them.
In your case, maybe you like the following
----------------------------------------------------------------
class String
    alias_method :__old_match, :=~
    def =~(obj)
        raise RuntimeError,
               "#{obj.nil? ? "nil" : obj.to_s} is not a Regexp but #{
obj.class}" unless Regexp === obj
        __old_match obj
    end # def =~(obj)
end # class String

puts "x" =~ %r{.}
puts "x" =~ nil

------------------------------

Hope this is helpfull

Cheers
Robert

--
Deux choses sont infinies : l'univers et la bóŐise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein

------art_1897_11014800.1143649582180--