Skip to content

Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

ARGF#close

ARGF.close → ARGF

Closes the current file and skips to the next file in ARGV. If there are no more files to open, just closes the current file. STDIN will not be closed.

For example:

$ ruby argf.rb foo bar

ARGF.filename  #=> "foo"
ARGF.close
ARGF.filename  #=> "bar"
ARGF.close
See also #binmode? #closed? #binmode #each also in 4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0