Skip to content

Commit b710293

Browse files
BurdetteLamarpeterzhu2118
authored andcommitted
[DOC] Doc for Module.nesting
1 parent 21f8472 commit b710293

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

eval.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,24 @@ ruby_exec_node(void *n)
329329

330330
/*
331331
* call-seq:
332-
* Module.nesting -> array
333-
*
334-
* Returns the list of +Modules+ nested at the point of call.
332+
* Module.nesting -> array
333+
*
334+
* Returns nested module as an array of Module objects:
335+
*
336+
* module M0
337+
* def self.speak = Module.nesting
338+
* module M1
339+
* def self.speak = Module.nesting
340+
* module M2
341+
* def self.speak = Module.nesting
342+
* end
343+
* end
344+
* end
345+
* M0.speak # => [M0]
346+
* M0.speak.first.class # => Module
347+
* M0::M1.speak # => [M0::M1, M0]
348+
* M0::M1::M2.speak # => [M0::M1::M2, M0::M1, M0]
335349
*
336-
* module M1
337-
* module M2
338-
* $a = Module.nesting
339-
* end
340-
* end
341-
* $a #=> [M1::M2, M1]
342-
* $a[0].name #=> "M1::M2"
343350
*/
344351

345352
static VALUE

0 commit comments

Comments
 (0)