Why does the third one not work as expected? It appears that
Dir.foreach will not work with patterns…
#!/usr/bin/ruby
s = “/etc/host*”
#1
l = Dir[s]
p l
#2
Dir.foreach("/etc") { |d| p d }
#3
Dir.foreach(s) { |d| p d }
#4
This is wasteful
l = Dir[s]
l.each { |f| p f }
···
–
^^^ Kurt
There is no good nor evil, just power.