Skip to content

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

instance method

Dir#close

close → nil

Closes the stream in self, if it is open, and returns nil; ignored if self is already closed:

Example
dir = Dir.new('example')
dir.read     # => "."
dir.close     # => nil
dir.close     # => nil
dir.read # Raises IOError.
See also #children #each #chdir #each_child also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0