Yukihiro - Please ensure backwards compatibility

I had this “problem”, too. I can’t see why Ruby is so verbose on
that
and doesn’t interpret foo.gsub[!](“bar”, …) as foo.gsub[!](/bar/,
…)
automagically…

First, because there is no such thing as magic*.

Secondly, I can’t speak for Matz, but when I want to use a regex, I
use a regex. I think ruby is perfectly justified in doing the same.
I think of “bar” as “match exactly ‘bar’”, but /bar/ as “match
anything with ‘bar’ in it”.

Should gsub() take a string (i.e. s.gsub!(“foo”, “bar”)) and do the
equivalent of:

s.replace(“bar”) if s == “foo”

(the non-bang version is left as an exercise for the reader)

? Don’t know. Don’t see it as a need, really. The “g” in “gsub”
isn’t really relevant in this context anyway; it would probably be
more meaningful in sub().

Either way, nothing to get upset over, certainly. Understand what’s
going on, fix old code that needs to be fixed, and move on.

Michael

  • personal pet peeve of “cutesy” terms. Probably a character flaw of mine.
···

Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/