On Nov 13, 10:04 am, James Edward Gray II <ja... / grayproductions.net>
wrote:
> The results were the same.

Not for all cases of 're' and 'input'.  Those variables were
unspecified.  If you wish to suggest an improvement to the code, it
must at least be equivalent to what was given.  It must produce the
same results for all such 're' and all such 'input'.  Sorry, the best
I can do is say it again:

The code was given as is, with unspecified variables 'input' and
're'.  You suggested removing the block.  That is wrong because the
behavior is not equivalent, as I just demonstrated.  You suggested
changing gsub to sub.  That is also wrong because the behavior is not
equivalent (and I assume this needs no demonstration).

But I guess it does need a demonstration:

   class Object
      def as
         yield self
      end
   end

   input = %w(aa bb)
   re = %r!a!

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

   puts filename
   # => __bb

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

   puts filename
   # => _abb

Not equivalent.