Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#each_child
(?::boolish with_directory) { (::Pathname) -> void } -> ::Array[::Pathname]
(?::boolish with_directory) -> ::Enumerator[::Pathname, ::Array[::Pathname]]
each_child(with_dirnames = true) {|entry| ... } → array_of_pathnames
each_child(with_dirnames = true) → new_enumerator
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1062
def each_child(with_directory=true, &b)
children(with_directory).each(&b)
end
With a block given and with_dirnames given as true (the default), yields a new pathname for each child of the entry represented by self; returns an array of those pathnames:
Example
Pathname('include').each_child {|child| p child } # #<Pathname:include/ruby> # #<Pathname:include/ruby.h> # => [#<Pathname:include/ruby>, #<Pathname:include/ruby.h>]
With a block given and with_dirnames given as false, yields a new pathname for each child of the entry represented by self with its dirname omitted; returns an array of those pathnames:
Example
Pathname('include').each_child(false) {|child| p child } # #<Pathname:ruby> # #<Pathname:ruby.h> # => [#<Pathname:ruby>, #<Pathname:ruby.h>]
Note that entries '.' and '..' are not children.
With no block given, returns a new Enumerator.