Global variable scoping problem.
This issue exists from 1.8 to ruby-head.
See the following example:
This demonstrates that $1 does not behave like a global variable. However it's listed by Kernel.global_variables as a global variable. And it's named like a global variable.
This leads to some confusion sometimes. See for example http://stackoverflow.com/q/11441782/773690
It may not be a good idea to fix this inconsistent naming, because it may break severaly things. However the fact that $1 and friends are not global variables should be clearly documented. And by the way: Ruby != Perl.
Or maybe make $1 a real global variable?
- re.c (rb_reg_s_last_match): Update $~ to reference Regexp documentation about "special global variables". [Bug #6723]
#3 Updated by Eric Hodel over 2 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100