Skip to content

Commit 675c68c

Browse files
authored
Add example for Dir.glob (crystal-lang#15171)
1 parent 6caea6a commit 675c68c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/dir/glob.cr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class Dir
3737

3838
# Returns an array of all files that match against any of *patterns*.
3939
#
40+
# ```
41+
# Dir.glob "path/to/folder/*.txt" # Returns all files in the target folder that end in ".txt".
42+
# Dir.glob "path/to/folder/**/*" # Returns all files in the target folder and its subfolders.
43+
# ```
4044
# The pattern syntax is similar to shell filename globbing, see `File.match?` for details.
4145
#
4246
# NOTE: Path separator in patterns needs to be always `/`. The returned file names use system-specific path separators.

0 commit comments

Comments
 (0)