From: Marc-Andre Lafortune Date: 2012-01-13T01:36:38+09:00 Subject: [ruby-core:42091] [ruby-trunk - Bug #5887] The documentation of Module.constants is incorrect Issue #5887 has been updated by Marc-Andre Lafortune. Shugo Maeda wrote: > 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 Actually, you can simply pass a parameter to `Module.constants` and the singleton method will call the instance method. The documentation should definitely reflect this too... I'll try to improve the doc. ---------------------------------------- Bug #5887: The documentation of Module.constants is incorrect https://bugs.ruby-lang.org/issues/5887 Author: Shugo Maeda Status: Assigned Priority: Normal Assignee: Eric Hodel Category: DOC Target version: ruby -v: ruby 2.0.0dev (2012-01-12 trunk 34015) [i686-linux] 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 -- http://bugs.ruby-lang.org/