Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In Ruby, references to constants are resolved at runtime, each time you access a constant. This is necessary, as constants can be added to or removed from any namespace dynamically. Moreover, the interpreter cannot replace the constant name with the constant value, as the value the named constant refers to can be changed as well.
Consequently, accessing a global constant, that is, a constant defined at the top level inside the class Object, is more costly than accessing a constant defined within the current or a nearby scope. For deeply nested classes, possibly also including a number of modules, you can more quickly resolve a constant reference by prefixing the constant with the namespace operator ::.