Method: Dir#each_child

Defined in:
dir.c

#each_child {|filename| ... } ⇒ Dir #each_childObject

Calls the block once for each entry except for “.” and “..” in this directory, passing the filename of each entry as a parameter to the block.

If no block is given, an enumerator is returned instead.

d = Dir.new("testdir")
d.each_child  {|x| puts "Got #{x}" }

produces:

Got config.h
Got main.rb

Overloads:

  • #each_child {|filename| ... } ⇒ Dir

    Yields:

    • (filename)

    Returns:


3052
3053
3054
3055
3056
3057
# File 'dir.c', line 3052

static VALUE
dir_each_child_m(VALUE dir)
{
    RETURN_ENUMERATOR(dir, 0, 0);
    return dir_each_entry(dir, dir_yield, Qnil, TRUE);
}