------art_5494_26144655.1143662565016
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

> >
> > Thanks for the suggestion, Robert.
> >
> > While I have no qualms about extending core classes, this sort of
> > adjustment feels like too... "brash"? of a modification for me.  :)
>
> You should have *some* qualms :-)  But in any case, this change is
> certainly one I wouldn't make.  I have no way of knowing whether
> someone has done this somewhere:
>
>    if str =~ re
>
> and not tested for re being nil because it doesn't affect the outcome
> of the test.
>
>
> David


Now I am very much against extending  core classes especally in commonly
used modules.
There was an interesting discussion  about Rails doing so to an extreme
extend.
However I do not hesitate a second to do it if I feel it gives me consistent
behaviour throughout my applications especially when I change some rather
"strange" behaviour.
It is always a good idea to be ready to break "rules" if there are good
reasons to do so.
This might as well be such a case.
Please note, and that is important, that my modification will break code
clearly in a well defined manner.
It all comes down to the following decision you have to make:
(A) Somebody might rely on
   "a" =~ nil returning false
in that case abandon!!! (and ask yourself why you have posted that
question!)

(B) Matching with nil is probably a mistake that will break the code later,
in other words your astonishement about that behaviour will be "common
sense", in that case the above extension of a core class is just a great
idea.

Robert

--
> David A. Black (dblack / wobblini.net)
> Ruby Power and Light, LLC (http://www.rubypowerandlight.com)
>
> "Ruby for Rails" chapters now available
> from Manning Early Access Program! http://www.manning.com/books/black
>
>


--
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_5494_26144655.1143662565016--