Kotlin Variables and Values – Kotlin Android – 03

posted in: Android, Kotlin, Software Engineering | 0

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.

Value declaration
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

Mutability
var x = 5 // `Int` type is inferred
x += 1

String interpolation
var a = 1// simple name in template:
val s1 = "a is $a"

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.