>
> >>    file_name = File.basename(input.join.gsub(re, "_"))
>
> > Not if re has \A or \Z.
>
> If the Regexp contain such an anchor, we probably shouldn't be
> calling gsub().

We don't know what's in re, so we can't make a judgment about gsub.

> My point is that your examples aren't convincing me.  Even if we have
> to support the anchor, I prefer your first example.  It's more
> obvious to me.  But I'll sleep OK tonight if we just agree to
> disagree on that.

Well I've used this for several years, and the examples I gave are
simplistic but illustrative.  The purpose was to understand the
general idea from the particular examples, even though they are
simplistic.

I've already suggested a less trivial example:

    files = stems.map { |f|
       f + "." + ext[platform]
    }.as { |t|
       z = transform1(t)
       transform2(basenames + transform3(t, z))
    }.map { |f|
       File.join(audio_dir, f)
    }

Your suggestion was to put the middle block into a method.  While that
may be best in certain circumstances, there is still a niche for small-
but-not-trivial cases where keeping the block may be clearer.