From: Robert Klemme Date: 2013-03-27T19:44:24+09:00 Subject: Re: Need help on ARGF#skip On Wed, Mar 27, 2013 at 9:28 AM, 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. > > 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? I suggest you report a bug. $ ruby -v ruby 1.9.3p385 (2013-02-06 revision 39114) [i386-cygwin] $ ruby -e 'p ARGF.argv; p ARGF.gets; ARGF.skip; p ARGF.argv; p ARGF.to_a; p ARGF.argv' <(seq 1 5) <(seq 10 15) ["/dev/fd/63", "/dev/fd/62"] "1\n" ["/dev/fd/62"] ["10\n", "11\n", "12\n", "13\n", "14\n", "15\n"] [] Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/