The Crystal Programming Language Forum

Can’t iterate over a Dir.new more than one time

Why is it impossible to iterate over Dir.new more than one time?

Usually I do:

my_dir = Dir.new “./“
my_dir.each_child { iterate success }
my_dir.each_child { doesn’t iterate again }

See https://github.com/crystal-lang/crystal/issues/8504. Is there a reason you need the Dir instance as opposed to just doing like Dir.each_child "./" { |x| puts x }?