diff options
| -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 |
