Ruby/File Directory/Dir.foreach

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Dir.entries returns an array with all the entries within the specified directory. Dir.foreach provides the same feature, but as an iterator:

Dir.foreach("/usr/bin") do |entry|
  puts entry
end



with Dir"s foreach

Dir.foreach( "/usr/local/src/ruby-1.8.6" ) { |e| puts e }