kotlin when to variable code example
Example 1: kotlin variable
val name = ”Marcin”
var age = 5
age++
Example 2: kotlin var val
+----------------+-----------------------------+---------------------------+
| | val | var |
+----------------+-----------------------------+---------------------------+
| Reference type | Immutable (once initialized | Mutable (can change value)|
| | can't be reassigned) | |
+----------------+-----------------------------+---------------------------+
| Example | val n = 20 | var n = 20 |
| | n++ | |
+----------------+-----------------------------+---------------------------+