Learn how to unwrap Nullables, force unwrap Nullables, and use the let statement.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4736-programming-in-kotlin/lessons/25
Learn how to unwrap Nullables, force unwrap Nullables, and use the let statement.
Can u explain the let syntax?i am not able to understand the syntax of let function
The let function is used on nullable variables. It allows you to safely use the variable in other calls.
For example:
var name: String? = “My Name”
name?.let {
it.toLowerCase()
}
you can also give “it” a name:
name?.let { nonNullableName →
nonNullableName.toLowerCase()
}