https://kotlinlang.org logo
#getting-started
Title
# getting-started
d

dalexander

09/28/2016, 6:23 PM
Could you give me an example of what you mean?
Copy code
fun someFunction() {
  val email = client?.personalInfo?.email
  // assuming message is a val, otherwise it may need similar treatment
  if(email != null && message != null) { mailer.sendMessage(email, message) }
}
is how I would change the above statement to take advantage of Kotlin’s smart casting. If email is method-local in this case then it’s safe from other threads modifying it, even if client.personalInfo.email gets changed in the meantime.