Skip to content

Commit

Permalink
Add docs for Dir#each_child (#11688)
Browse files Browse the repository at this point in the history
Co-authored-by: Johannes Müller <[email protected]>
Co-authored-by: Sijawusz Pur Rahnama <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2022
1 parent a0e6b45 commit 045ec55
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/dir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 045ec55

Please sign in to comment.