aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-05 14:32:45 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-05-05 14:35:35 +0900
commit374c8f4ebab1a740990330c732b9de965c5e8d10 (patch)
tree7b7f1f4b5ef6d3c5aa4481abce8a62ac8c4ac2ea /io.c
parent84e71e9fc1965d00013fea1bea1ce22aa7e7e619 (diff)
downloadruby-374c8f4ebab1a740990330c732b9de965c5e8d10.tar.gz
Fixed about ARGF.lineno
[Bug #15823]
Diffstat (limited to 'io.c')
-rw-r--r--io.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/io.c b/io.c
index ed8bc1ee3b..32e3a39e22 100644
--- a/io.c
+++ b/io.c
@@ -12393,13 +12393,21 @@ argf_block_call_line(ID mid, int argc, VALUE *argv, VALUE argf)
* a single file consisting of the concatenation of each named file. After
* the last line of the first file has been returned, the first line of the
* second file is returned. The +ARGF.filename+ and +ARGF.lineno+ methods can
- * be used to determine the filename and line number, respectively, of the
- * current line.
+ * be used to determine the filename of the current line and line number of
+ * the whole input, respectively.
*
* For example, the following code prints out each line of each named file
* prefixed with its line number, displaying the filename once per file:
*
* ARGF.each_line do |line|
+ * puts ARGF.filename if ARGF.file.lineno == 1
+ * puts "#{ARGF.file.lineno}: #{line}"
+ * end
+ *
+ * While the following code prints only the first file's name at first, and
+ * the contents with line number counted through all named files.
+ *
+ * ARGF.each_line do |line|
* puts ARGF.filename if ARGF.lineno == 1
* puts "#{ARGF.lineno}: #{line}"
* end