Constant
A constant is a named program value or binding that is fixed or intended not to change after initialization.
The Well-Grounded Rubyist, Fourth Edition
A constant is a Ruby identifier whose name begins with an uppercase letter and conventionally denotes a value intended not to be reassigned.
- How it is used
- Names classes and stores shared class data while making nested values reachable through class or module paths.
- How deep it goes
- Works through assignment, reassignment warnings, object mutation, and relative versus absolute lookup.
- Examples
- Uses a class’s venue array, Math::PI, and nested X definitions to illustrate storage and lookup.
- What you can do after
- Evaluate/understand Ruby constant lookup and distinguish reassignment warnings from changes to referenced objects.
Read how The Well-Grounded Rubyist, Fourth Edition explains constant →
Modern C
A named constant is a constant associated with an explanatory name representing a particular meaning.
- How it is used
- Uses names to preserve distinct meanings, improve maintenance, and identify constants as significant artifacts.
- How deep it goes
- Defines naming principles and surveys enumeration constants, macros, and temporary objects without detailing their syntax.
- Examples
- Uses repeated 3 values, named string arrays, and identifiers such as corvid_num, M_PI, false, true, SIZE_MAX, and fortytwo.
- What you can do after
- Evaluate which repeated values require names and distinguish enumeration constants, macros, and temporary objects by role.
Modern C, Third Edition
A named constant is a program constant given an identifier so code can refer to its meaning instead of repeating its value.
- How it is used
- Uses named constants to express meaning, prevent repeated special values, and improve maintenance and portability.
- How deep it goes
- Distinguishes enumeration constants, macros, compound literals, and C23 constexpr objects but defers their detailed mechanics.
- Examples
- Uses repeated array size 3, corvid_num, M_PI, false, true, SIZE_MAX, and fortytwo as naming examples.
- What you can do after
- Apply semantic naming to replace repeated values and select among C mechanisms for named or compile-time constants.
Related concepts
- inputincludes · An input is a value, information, or signal supplied to a system, computation, or interface for processing or to influence its behavior.
- const qualifierused by · A language feature that marks a value, binding, or access path as constant, restricting reassignment or modification according to the language’s rules.
- enum constantincludes · An enumeration constant is a named member of an enumeration representing one distinct enumerated value.
- double-colon constant lookup tokenused by · The double-colon constant lookup token is Ruby's :: syntax for qualifying and resolving a constant through a class or module hierarchy.
- static fieldcontrasts with · A named variable whose storage is associated with a class or has static duration, rather than being allocated separately for each object instance or function call.
- genericscontrasts with · Generics are programming-language constructs that parameterize or generalize types and operations so they can apply to multiple concrete types or input forms.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


