each

dir.each { |filename| block } â dir
dir.each â an_enumerator
Instance Public methods

Calls the block once for each entry in this directory, passing the filename of each entry as a parameter to the block.

If no block is given, an enumerator is returned instead.

1
2
d = Dir.new("testdir")
d.each  {|x| puts "Got #{x}" }

produces:

1
2
3
4
Got .
Got ..
Got config.h
Got main.rb
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.