-
Book Overview & Buying
-
Table Of Contents
Android Programming for Beginners - Fourth Edition
By :
In Kotlin, all types can be either modifiable or not. When something is modifiable, the language we can use to describe it can be either 'variable' or mutable (think of 'mutate' or 'change'). We use the keyword var in code to denote a mutable value.
If a type is not variable/mutable/modifiable, we say it is immutable. In Kotlin, we refer to an unchangeable/immutable value in our code as a val.
In summary so far:
var keyword to declare a variable of a mutable typeval keyword to declare an immutable/unchangeable typeAs we progress through the book, there are advantages to this preference for immutability, and there are also many nuances to what mutable and immutable mean in practice, depending on the context.
We now know the changeability criteria for our types, but we haven't seen any types yet.