On Nov 13, 2007, at 8:50 AM, furtive.clown / gmail.com wrote:

> You suggested changing gsub to sub.  That is also wrong because the  
> behavior is not equivalent (and I assume this needs no demonstration).

Your code:

   class Object
      def as
         yield self
      end
   end

   input = %w(a b)
   re = %r!a\Z!

   filename = input.map { |t|
      t.gsub(re, "_")
   }.join.as { |t|
      File.basename(t)
   }

   puts filename
   # => _b

Switching to sub():

   class Object
      def as
         yield self
      end
   end

   input = %w(a b)
   re = %r!a\Z!

   filename = input.map { |t|
      t.sub(re, "_")
   }.join.as { |t|
      File.basename(t)
   }

   puts filename
   # => _b

The results were the same.

James Edward Gray II