Properties
So far, we have talked about objects and classes. To recap, we know that classes are the definition of an object, where we capture the properties and actions that this object will be able to do. In other words, it is the template with which we will create the object. Now, we are going to see how to define properties.
Properties within OOP are the characteristics of an object; in some programming languages, they are called attributes. In Kotlin, the standard term is properties, so that is what we will use throughout this book. These characteristics are what define an object; for example, a book may have a title and an author. Properties can be explicitly declared with their types, and that’s the approach we’ll start with to make everything clear.
Later in Kotlin, you’ll see that specifying the type of a property is not always necessary. The compiler can automatically determine the type based on the assigned value. This is known as type inference...