Assign this or that in Kotlin

Find this useful? Support us: Star on GitHub 6
Category: Other | Language: Kotlin

In Kotlin, the "this" and "that" keywords are not used for variable assignment. Instead, you can assign values directly to variables using the equals sign (=). Here is an example:

// Assigning a value to a variable called "this"
val thisIsAString = "This is a string."

// Assigning a value to a variable called "that"
val thatIsANumber = 42

In the above example, we assign a string value to a variable called thisIsAString using the val keyword and an equals sign (=). Likewise, we assign an integer value to a variable called thatIsANumber. These variables can be used later in the code to retrieve or modify their values.