Overview - Constants in classes
What is it?
Constants in classes are values defined inside a class that do not change during the program. They are written with capital letters and are shared by all objects of that class. Constants help keep important values safe and easy to find. They are different from regular variables because they are meant to stay the same.
Why it matters
Constants exist to hold fixed values that many parts of a program can use without risk of accidental change. Without constants, programmers might accidentally change important values, causing bugs and confusion. Constants make code clearer and safer by showing which values should not change.
Where it fits
Before learning constants in classes, you should understand basic Ruby classes and variables. After this, you can learn about class variables, instance variables, and how constants interact with inheritance and modules.