In this video, we’re going to explain kotlin variables, how to define them, how to set or instantiate them, how to caste them and how they work under the hood.
Make sure you subscribe to the channel to get updates on future Kotlin videos as well as other videos on iOS and game development that I have on this channel.
So let’s get started by using our project from the first video. Make sure you watch it if you need help setting up Android Studio, otherwise, let’s jump into it.
val a: Int = 1 // immediate assignment
val someString:String = “”
val b = 2 // `Int` type is inferred
val c: Int // Type required when no initializer is provided
c = 3 // deferred assignment
var x = 5 // `Int` type is inferred
x += 1
var a = 1// simple name in template:
val s1 = "a is $a"