The return value of ARGF.file#lineno
differs from that of MRI
#4497
Labels
Milestone
ARGF.file#lineno
differs from that of MRI
#4497
Environment
(uname -a: Linux name-of-my-PC 4.4.0-62-generic * JRUBY-6077 Allow loading a Ruby source file from the class path using the fully qualified name #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux)
Expected Behavior
When you read several files via
ARGF,
the value ofARGF.file#lineno
is expected to be reset to 1 each time a new file is read from command line arguments.I cannot find an appropriate explanation in ruby-doc.org, but in the documentation in Japanese, it is explained that
ARGF.lineno
returns the current line number as if the lines are read from a single file consisting of files given as command line arguments, whileARGF.file#lineno
returns the line number for an individual file in the arguments. And this is the actual behavior of MRI.The behavior of JRuby seems to be the same as
ARGF.lineno
.Actual Behavior
Supposing you have 3 files first.txt, second.txt and third.txt whose lines are "a b c", "A B C D" and "alpha beta" respectively:
The text was updated successfully, but these errors were encountered: