我特意想做的是:
Dir.new('some_directory').each do |file| # is there a way to refer to the string 'some_directory' via a method or variable? end
谢谢!
不过你可以这样做:
Dir.new(my_dir = 'some_directory').each do |file| puts "#{my_dir} contains #{file}" end