Group Group Group Group Group Group Group Group Group

Programming in Kotlin - Part 25: More Nullables | Ray Wenderlich

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

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()
}