foreach

Dir.foreach( dirname ) {| filename | block } â nil
Dir.foreach( dirname ) â an_enumerator
Class Public methods

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

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

1
Dir.foreach("testdir") {|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.