diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2026-05-07 17:16:14 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu.nakada@gmail.com> | 2026-05-13 17:37:48 +0900 |
| commit | 407398b079b9191740b28856a8036ca01810144c (patch) | |
| tree | 3a86a67f0712587c4ef81fccfd86be9f40fce53a | |
| parent | 997e11cf379438c173749c10bbf40edc83cac9de (diff) | |
pathname: Use Dir.children
| -rw-r--r-- | pathname_builtin.rb | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 707336679f..42d33e7eda 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -766,15 +766,12 @@ class Pathname # def children(with_directory=true) with_directory = false if @path == '.' - result = [] - Dir.foreach(@path) {|e| - next if e == '.' || e == '..' - if with_directory - result << self.class.new(File.join(@path, e)) - else - result << self.class.new(e) - end - } + result = Dir.children(@path) + if with_directory + result.map! {|e| self.class.new(File.join(@path, e))} + else + result.map! {|e| self.class.new(e)} + end result end |
