How would I best avoid null issues in the followin...
# codingconventions
s
How would I best avoid null issues in the following code:
Copy code
data class Person(
        val name: String,
        val dateOfBirth: Date? = null
)

val people = listOf<Person>()

fun printNameAndDob(name: String, dob: Date) {
    println("Name: $name, DOB: $dob")
}

people.filterNot { it.dateOfBirth == null }
        .forEach { printNameAndDob(it.name, it.dateOfBirth) } // this won't work as dateOfBirth could be null
Are there any smart tricks I could use to “smart cast” the property somehow? Thanks! ❤️ 😀