Method: Module#constants

Defined in:
variable.c

#constants(inherit = true) ⇒ Array

Returns an array of the names of the constants accessible in mod. This includes the names of constants in any included modules (example at start of section), unless the inherit parameter is set to false.

The implementation makes no guarantees about the order in which the constants are yielded.

IO.constants.include?(:SYNC)        #=> true
IO.constants(false).include?(:SYNC) #=> false

Also see Module#const_defined?.



3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
# File 'variable.c', line 3508

VALUE
rb_mod_constants(int argc, const VALUE *argv, VALUE mod)
{
    bool inherit = true;

    if (rb_check_arity(argc, 0, 1)) inherit = RTEST(argv[0]);

    if (inherit) {
        return rb_const_list(rb_mod_const_of(mod, 0));
    }
    else {
        return rb_local_constants(mod);
    }
}