From: "nobu (Nobuyoshi Nakada)" Date: 2013-03-28T21:35:03+09:00 Subject: [ruby-core:53797] [Backport 200 - Backport #8175][Closed] ARGF#skip doesn't work as documented. Issue #8175 has been updated by nobu (Nobuyoshi Nakada). Status changed from Open to Closed pritamdey (pritam dey) wrote: > from the doc: http://www.ruby-doc.org/core-2.0/ARGF.html#method-i-skip > > ARGF#skip :- Sets the current file to the next file in ARGV. If there > aren't any more files it has no effect. ARGF isn't a class, so it's ARGF.skip. > Code - I: > Question- Why after the line B, line in A printing all the file names? ARGF.skip just sets the current file, argv is untouched. > Code II: > Question- Why after the line A, line in B printing `a.txt` as current > file? Before the line A no files is assigned to the current file, and ARGF.skip tries to open the next file, "a.txt". ---------------------------------------- Backport #8175: ARGF#skip doesn't work as documented. https://bugs.ruby-lang.org/issues/8175#change-37996 Author: pritamdey (pritam dey) Status: Closed Priority: Normal Assignee: Category: Target version: from the doc: http://www.ruby-doc.org/core-2.0/ARGF.html#method-i-skip ARGF#skip :- Sets the current file to the next file in ARGV. If there aren't any more files it has no effect. Tried the codes as below: Code - I: p RUBY_VERSION p ARGF.argv ARGF.skip #~~>B p ARGF.argv #~~> A Output: D:\Rubyscript>ruby true.rb a.txt b.txt "2.0.0" ["a.txt", "b.txt"] ["a.txt", "b.txt"] Question- Why after the line B, line in A printing all the file names? Code II: p RUBY_VERSION p ARGF.argv ARGF.skip #~~>A p ARGF.filename #~~>B p ARGF.argv output: D:\Rubyscript>ruby true.rb a.txt b.txt "2.0.0" ["a.txt", "b.txt"] "a.txt" ["b.txt"] Question- Why after the line A, line in B printing `a.txt` as current file? output doesn't match with the official doc,after `skip`. -- http://bugs.ruby-lang.org/