On Fri, Jun 10, 2011 at 1:28 AM, Jan Lelis <mail / janlelis.de> wrote:

> "string".gsub(/com(plex)_reg(ex)/){
>  # use $1, $2, ...
> }
>
> To get back to the original problem, I'd prefer: $item (which is -of
> course- not a global variable).
>
> PS: Since $dollar variables are rarely used anyway, lets transform them all
> into special variables :D
>

I think the ${1,2,3,...} variables match the gsub(regex, "a $1 replacement
$2 here $3").

While using $item, or any other identifier, as the implicit argument might
make some code a few characters shorter to write, what other benefits are
there? All I can see is that it adds one more thing to learn in the language
and introduces greater complexity, both for people who've never seen it, and
for scoping rules. I see nothing wrong with the explicit { |item| ... }.
It's readable, it works.