Skip to content

Commit 776dfb3

Browse files
committed
[DOC] Improve docs for Module.constants
1 parent bc849a1 commit 776dfb3

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

eval.c

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -368,24 +368,25 @@ rb_mod_nesting(VALUE _)
368368

369369
/*
370370
* call-seq:
371-
* Module.constants -> array
372-
* Module.constants(inherited) -> array
371+
* Module.constants -> array
372+
* Module.constants(inherited) -> array
373373
*
374-
* In the first form, returns an array of the names of all
375-
* constants accessible from the point of call.
374+
* When no argument is provided, returns the names of all constants
375+
* accessible from the point of call as an array of symbols.
376376
* This list includes the names of all modules and classes
377377
* defined in the global scope.
378378
*
379-
* Module.constants.first(4)
380-
* # => [:ARGF, :ARGV, :ArgumentError, :Array]
379+
* class Foo
380+
* HELLO = 1
381381
*
382-
* Module.constants.include?(:SEEK_SET) # => false
382+
* def self.my_constants = Module.constants
383+
* end
383384
*
384-
* class IO
385-
* Module.constants.include?(:SEEK_SET) # => true
386-
* end
385+
* Foo.my_constants - Module.constants # => [:HELLO]
387386
*
388-
* The second form calls the instance method +constants+.
387+
* With argument +inherited+ given, it is equivalent to calling
388+
* Module#constants on the class +Module+. See Module#constants
389+
* for more details.
389390
*/
390391

391392
static VALUE

0 commit comments

Comments
 (0)