Ruby 2.4.1 Dir.children (dirname) returns the "undefined method` children 'for Dir: Class "

I am new to Ruby and am trying to learn it. I am using the latest version of Ruby (2.4.1) and the interactive Ruby Shell.

I met a method childrenin the classroom Dir. I tried an example from the documentation :

Dir.children("testdir")   #=> ["config.h", "main.rb"]

but it does not work, because I get the following message:

undefined method `children' for Dir:Class

What am I missing?

+6
source share
1 answer

This seems to be a kind of documenting mess.

Dir.children Feature # 11302 Ruby . , , , , Ruby 2.4, dir.c Ruby 2.4.1 . , http://ruby-doc.org/

, , . :

Dir.entries('testdir') - [".", ".."]

, Dir.children('testdir') Ruby HEAD.

+8

All Articles