Project

General

Profile

Actions

Bug #15823

closed

ARGF.lineno behavior and documentation disagree

Added by plujon (Jon Wilkes) over 5 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
[ruby-core:92539]

Description

The documentation for ARGF.each at http://ruby-doc.org/core-2.6.3/ARGF.html#method-i-each
describes ARGF.lineno as if it behaved like ARGF.file.lineno, when it behaves for me like $.

Here's the sample code from the documentation:

ARGF.each_line do |line|
  puts ARGF.filename if ARGF.lineno == 1
  puts "#{ARGF.lineno}: #{line}"
end

A shell one-liner demonstration:

for i in a b; do echo $i>$i; done; ruby -e 'ARGF.each_line do print " #{ARGF.filename} #{ARGF.lineno}"; end; puts' a b
 a 1 b 2

The documents indicate that should be a 1 b 1'

Are the documents correct or the implementation?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0