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 « File Directory « Ruby






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

 

Related examples in the same category

1.with Dir's foreach