Values declared with var
are a lot like C# variables and can be re-assigned.
C#
string firstName = "Bobby";
var lastName = "McBobface"; // Type can be inferred
lastName = "Smith";
Kotlin
var firstName: String = "Bobby"
var lastName = "McBobface" // Type can be inferred
lastName = "Smith"
Note: the type comes after the variable name.
Note: no line-end semicolons. (Semicolons are very rare in Kotlin - we’ll see one later…)