On Aug 17, 9:47 am, "Robert Klemme" <shortcut... / googlemail.com>
wrote:
> Here's another solution that avoids reading the large file into mem
> but it does not write out names ordered:
>
> require 'set'
> names = Set.new(File.readlines("filenames.txt").each {|s| s.chomp!})
>
> File.open("allfilespath.txt") do |io|
>   io.each do |line|
>     line.chomp!
>     puts line if names.includes? File.basename(line)
>   end
> end
>
> Kind regards
>
> robert

Is there a reason to do it this way instead of the slightly more
compact way below?

File.open("allfilespath.txt").each_line do |line|
  line.chomp!
  puts line if names.includes? File.basename(line)
end

Is there a difference in behavior, or only in appearance?