Constants
Although not enforced by the compiler, constants are usually named with all capital letters and underscores to separate words.
A constant definition can invoke methods and have complex logic:
is the current line number in the currently executing crystal file. When __LINE__
is used as a default parameter value, it represents the line number at the location of the method call.
is the line number of the end
of the calling block. Can only be used as a default parameter value.
__DIR__
references the full path to the directory where the currently executing crystal file is located.
Dynamic assignment
Dynamically assigning values to constants using the or the multiple assignment is not supported and results in a syntax error.