Kotlin 2 · Basics and null safety

Declare variables

val is read-only and var is mutable. Types are inferred.

val name = "Ada"        // read-only
var score = 0            // mutable
score += 10

Official Kotlin 2 documentation

More basics and null safety commands

All basics and null safety commands · Kotlin 2 cheatsheet

Was this page helpful?