Working with constants in V
Sometimes, your program must have certain values that never change throughout the application's lifetime. V facilitates the declaration of such values as constants using the const
keyword. A constant, once assigned to a value, can never be changed. Unlike variables that can only be declared inside the functions, V allows constants to be declared outside of the functions, and they can be scoped at the module level.
In V, you can define constants that are having values of primitive types such as int, string, bool. In addition to it, you can also define constants of complex values such as structs
. We will learn how to define complex constants in the following sections of this chapter.
Naming conventions for constants
Similar to variables, constants have the following naming conventions:
- The name of a constant can only start with the lowercase alphabet.
- The name of a constant cannot contain the uppercase alphabet.
- Special characters...