How much code would break by having an optional third argument, defaulting
to current behaviour?
def sub!(pattern, substitution, no_change_gives=nil)
#...
end
then you could have
astring.sub!(/wine/, "beer", astring)
so the unchanged string gets passed on if there is no change, or
astring.sub!(/wine/, "beer", "vodka")
or whatever.
Hugh