ARGF.lineno

e$B$k$S$-$A$G$9!#e(B

ARGF.linenoe$B$Oe(BRuby
[email protected]$H=hM}Cf$N%U%!%$%k$N9THV9f$rJV$9;EMM$KJQ$o$C$?$N$G$9$+!)e(B

RUBY_VERSION # => “1.8.6”
RUBY_RELEASE_DATE # => “2007-09-24”
ARGV.replace %w[ab.txt cd.txt]
ARGF.each_line do |line|
filename = ARGF.filename
lineno_all = ARGF.lineno
lineno = ARGF.file.lineno
puts “#{lineno_all}:#{lineno}:#{filename}”
end

>> 1:1:ab.txt

>> 2:2:ab.txt

>> 3:1:cd.txt

>> 4:2:cd.txt


RUBY_VERSION # => “1.9.0”
RUBY_RELEASE_DATE # => “2008-02-06”
ARGV.replace %w[ab.txt cd.txt]
ARGF.each_line do |line|
filename = ARGF.filename
lineno_all = ARGF.lineno
lineno = ARGF.file.lineno
puts “#{lineno_all}:#{lineno}:#{filename}”
end

>> 1:1:ab.txt

>> 2:2:ab.txt

>> 1:1:cd.txt

>> 2:2:cd.txt

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs