added val and var (#31647)
This commit is contained in:
committed by
The Coding Aviator
parent
3d358802b8
commit
ef8fbbc544
@ -21,8 +21,8 @@ val lastName = "Musk"
|
|||||||
In addition, notice the usage of `val` variable type, here is how it behaves
|
In addition, notice the usage of `val` variable type, here is how it behaves
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
firstName = "Mark" // can be changed
|
var firstName = "Mark" // can be changed
|
||||||
lastName = "Zuckerberg" // cannot be changed
|
val lastName = "Zuckerberg" // cannot be changed
|
||||||
lastName = 12 // Error: type mismatch
|
lastName = 12 // Error: type mismatch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user