ARGF.close and ARGF.skip seem to be similar here:
$ ruby argf.rb foo bar
ARGF.filename #=> "foo"
ARGF.skip
ARGF.filename #=> "bar"
$ ruby argf.rb foo bar
ARGF.filename #=> "foo"
ARGF.close
ARGF.filename #=> "bar"
The examples are from ruby-doc.org, I don’t know the difference between
these two methods.
QUOTE “If you don’t understand what closing a file does, then that is a
different matter altogther. For instance, methods like fork() and
exec() pass open file handles to subprocesses.”
I wish this is the way it worked. Looking ar the ARGF code, #skip
closes the current file.
wrong QUOTE;
“The docs seem to indicate the difference pretty well. skip()
moves to the next file. close() closes the current file and then moves
to the next file.”
Joey Z. wrote in post #1003902:
ARGF.close and ARGF.skip seem to be similar here:
$ ruby argf.rb foo bar
ARGF.filename #=> "foo"
ARGF.skip
ARGF.filename #=> "bar"
$ ruby argf.rb foo bar
ARGF.filename #=> "foo"
ARGF.close
ARGF.filename #=> "bar"
The examples are from ruby-doc.org, I don’t know the difference between
these two methods.
I dunno. The docs seem to indicate the difference pretty well. skip()
moves to the next file. close() closes the current file and then moves
to the next file.
If you don’t understand what closing a file does, then that is a
different matter altogther. For instance, methods like fork() and
exec() pass open file handles to subprocesses.
On Jul 8, 2012, at 19:07 , richard bucker wrote:
wrong QUOTE;
“The docs seem to indicate the difference pretty well. skip()
moves to the next file. close() closes the current file and then moves
to the next file.”
File a bug or, better, a patch.