It can be used to set a value once, and then it will be available for all the other classes in the same file.
It can also be used to set a value for all the classes in the same project.
Constant is easy to read and understand because it uses snake case notation (e.g., CONSTANT_NAME).
Variables are containers that can hold any kind of data. They can be used to store numbers, letters, or even complex mathematical expressions.
Constant values are fixed values that cannot be changed. Constants are often used to store a number, letter or a combination of both.
The syntax for defining constants in Ruby is:
CONST = "value"
# Constants can be assigned values at the time of their definition.
Constant: A constant is a fixed value that can be utilised in algebraic expressions and equations. A constant has a fixed value that does not vary over time. The size of a shoe, a cloth, or any other item of clothing, for example, will not change at any time.
The value of a constant variable cannot be changed or updated anywhere in your application. When a constant variable is declared, it must be initialised.