Problem with the command Dir.entries

Hello, today I used Dir.entries functionnality to list files into a directory, but I seen a problem, this fonction take as well hidden files. How can I prevent that ? Can I had a filter or something like that ?

this should work?

Dir.entries("/my-dir").reject! &.starts_with?('.')
1 Like

This work, thanks you !

But what is this syntax ??? Specially that:


1 Like

Oh yes I forgot that. Thanks you !

If all you are trying to remove is just "." and "..", prefer Dir.children instead.


Oh yes perfect, thanks you