constants

Module.constants â array
Module.constants(inherited) â array
Class Public methods

In the first form, returns an array of the names of all constants accessible from the point of call. This list includes the names of all modules and classes defined in the global scope.

1
2
3
4
5
6
7
8
Module.constants.first(4)
   # => [:ARGF, :ARGV, :ArgumentError, :Array]
 
Module.constants.include?(:SEEK_SET)   # => false
 
class IO
  Module.constants.include?(:SEEK_SET) # => true
end

The second form calls the instance method constants.

doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.