From: aurelianito Date: 2005-11-09T04:52:12+09:00 Subject: gsub and gsub! are inconsistent Hi all! I've been trying to optimize the code a_string.gsub(/pattern_1/, "REPLACE_1").gsub(/pattern_2/, "REPLACE_2").gsub(/PATTERN_3/,"REPLACE_3"). with a_string.gsub(/pattern_1/, "REPLACE_1").gsub!(/pattern_2/, "REPLACE_2").gsub!(/pattern_3/,"REPLACE_3") (note the '!' on the second and third gsub). IMHO, this two blocks of pseudocode should behave in the same way, but if the second pattern don't matches, it returns null on the second version, and then generates an exception. Why is it than the destructive gsub behaves differently? Do you think that the current behaviour is the right behaviour? Why? Please comment, Aureliano.