In Ruby 2.6, same methods are added as instance methods on Dir class.
Dir#children returns array of all the filenames except . and .. in the directory.
Dir#each_child yields all the filenames and operates on it.
Let’s have a look at examples to understand it better.
Dir#each_child iterates and calls block for each file entry in the given directory. It uses filename as a parameter to the block.
If we don’t pass any block to each_child, it returns enumerator instead.