The general syntax for declaring a property is as follows:
var/val<propertyName>:<PropertyType>[=<property_initializer>] [<getter>] [<setter>]
Both the initializer and the getter/setter parts of the preceding code are optional. Furthermore, the property type can also be omitted if the compiler can infer it; however, for code clarity, it is advisable to add the property type if it is not immediately obvious.
If you define a read-only property by using the val keyword, then only the getter will be generated. Say that you have to define a class hierarchy for shapes in a painting application. You might define a property for the area. The following example is a typical implementation for such property when it comes to a Rectangle class:
interface Shape { val area: Double } class Rectangle...