From: Mike Steiner Date: 2007-05-27T08:57:31+09:00 Subject: are MatchData objects mutable? ------=_Part_98645_21719045.1180223851654 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline A few times in my programs I've tried to modify elements of the array returned by .match, and it always causes strange errors later in my code. For example, if I do: s = "aaa bbb ccc" m = /(.*) (.*) (.*)/.match(s) m[1].sub! ( "aa" , "" ) I get strange results, but if I instead do: s = "aaa bbb ccc" m = /(.*) (.*) (.*)/.match(s) x = m[1].dup x.sub! ( "aa" , "" ) it works fine. What's going on? Mike Steiner ------=_Part_98645_21719045.1180223851654--