diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-07-31 14:14:59 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-07-31 14:14:59 +0000 |
commit | 9e4ab409b50dfef68a97b36f2ec50e344c9980ac (patch) | |
tree | d1e605926d9014647e7fd2a0e36d4d7f61c2e9a5 /io.c | |
parent | 41d6bc37e95bb51456d0d27da832c51cf701b5ee (diff) |
merge revision(s) 374c8f4ebab1a740990330c732b9de965c5e8d10: [Backport #15823]
Fixed about ARGF.lineno
[Bug #15823]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -12313,13 +12313,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 |