From 045ec5598bfe6d3300d71bd05e0728bbc8b3f8c8 Mon Sep 17 00:00:00 2001 From: Jack Date: Sat, 29 Jan 2022 07:12:52 -0600 Subject: [PATCH] Add docs for `Dir#each_child` (#11688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johannes Müller Co-authored-by: Sijawusz Pur Rahnama --- src/dir.cr | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/dir.cr b/src/dir.cr index a211f86a1794..3966c275cd8d 100644 --- a/src/dir.cr +++ b/src/dir.cr @@ -96,6 +96,21 @@ class Dir end end + # Returns an iterator over of the all entries in this directory except for `.` and `..`. + # + # See `#each_child(&)` + # + # ``` + # Dir.mkdir("test") + # File.touch("test/foo") + # File.touch("test/bar") + # + # dir = Dir.new("test") + # iter = d.each_child + # + # iter.next # => "foo" + # iter.next # => "bar" + # ``` def each_child : Iterator(String) ChildIterator.new(self) end