From: Charles Oliver Nutter Date: 2009-10-26T10:38:54+09:00 Subject: [ruby-core:26303] IO.foreach (and friends) effect on $< and $. I have a few questions about how the line-by-line IO operations are *supposed* to affect the ARGF global $< and the line number global $. First off, it seems a bit inconsistent whether $< should be updated for non-ARGF line iterations: ~/projects/jruby ��� ruby -v -e 'p $<.lineno; IO.foreach("build.xml") {}; p $<.lineno' ruby 1.8.6 (2008-08-11 patchlevel 287) [universal-darwin9.0] 0 1775 ~/projects/jruby ��� ruby1.8.7 -v -e 'p $<.lineno; IO.foreach("build.xml") {}; p $<.lineno' ruby 1.8.7 (2009-09-11 patchlevel 202) [i686-darwin9.8.0] 0 1775 ~/projects/jruby ��� ruby1.9 -v -e 'p $<.lineno; IO.foreach("build.xml") {}; p $<.lineno' ruby 1.9.2dev (2009-07-23 trunk 24248) [i386-darwin9.7.1] 0 0 It seems like 1.9 is "correct" here. JRuby acts like 1.8 regardless of 1.8 or 1.9 mode. Second, the $. variable. It appears to be consistently updated for all Ruby versions, but I wonder whether it's useful if it isn't thread-local. Thread-local would be better because multiple threads iterating lines would not all be setting the same variable. - Charlie