https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
i

Ink

09/02/2021, 9:37 AM
Copy code
fun findName(personList: PersonList) : String?{
    var name: String? = null
    personList.person.forEach {
        name =  it.name
    }
    return name
}
Can I simplify that code?
k

Karel Petránek

09/02/2021, 9:38 AM
What is the code supposed to do? Try
personList.person.lastOrNull()?.name
2 Views