In Scala val is used for creating constants and the naming convention for Scala Constants is to use UpperCamelCase convention. (https://docs.scala-lang.org/style/naming-conventions.html#constants-values-variable-and-methods)
A generalization for this rule should be all vals should be in UpperCamelCase.
i.e. if a variable is declared using val keyword its name should be in UpperCamelCase. However I see examples on Scala's website exploiting this rule.
What am I missing here?
Put simply:
A constant only has one value while the program is running. It is either fixed at compile time, e.g. Pi, HoursInDay, or is an immutable value inside a top-level object.
A val is an immutable variable. It cannot be changed once it is set, but it may be set to different values each time the containing code is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With