From 407398b079b9191740b28856a8036ca01810144c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 7 May 2026 17:16:14 +0900 Subject: pathname: Use Dir.children --- pathname_builtin.rb | 15 ++++++--------- 1 file 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 -- cgit v1.2.3