Project

General

Profile

Actions

Bug #5887

closed

The documentation of Module.constants is incorrect

Added by shugo (Shugo Maeda) over 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-01-12 trunk 34015) [i686-linux]
Backport:
[ruby-core:42080]

Description

The documentation of Module.constants says "Returns an array of the names of all constants defined in the system. This list includes the names of all modules and classes." However, Module.constants returns the names of the constants accessible at the place where the method is called:

class A
X = 1
p Module.constants.include?(:X) #=> true
end

Could someone fix the documentation? I can't write a proper English documentation.

OT: I think Module.constants should be renamed in the future, because Module.constants is confusing with Module#constants. Why the hell do I have to write the following tricky code to invoke Module#constants on Module itself?

p Module.instance_method(:constants).bind(Module).call

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0