In Kotlin there are:
val- readonly propertyconst val- compile-time constants
From the documentation:
Compile-Time Constants
Properties the value of which is known at compile time can be marked as compile time constants using the
constmodifier. Such properties need to fulfill the following requirements:
- Top-level or member of an object
- Initialized with a value of type String or a primitive type
- No custom getter
Given that kotlin compiler does know to identify initialized values (such as there is no need defining the variable type in an initializer):
- Why does the compiler needs the programmer's assistance?
- Can't it identify "properties the value of which is known at compile time" and "add" the
constmodifier by itself?