Project

General

Profile

Actions

Backport #8175

closed

ARGF#skip doesn't work as documented.

Added by pritamdey (arup rakshit) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Assignee:
-
[ruby-core:53770]

Description

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.

Actions

Also available in: Atom PDF

Like0
Like0