Kotlin - equivalence to Swift's combination of "if let + cast" : <p>I'm trying to find out how to achieve the combination of "if let + cast" in kotlin:</p>

<p>in swift:</p>

<pre><code>if let user = getUser() as? User {
   // user is not nil and is an instance of User
}
</code></pre>

<p>I saw some documentation but they say nothing regarding this combination</p>

<p><a href="https://medium.com/@adinugroho/unwrapping-sort-of-optional-variable-in-kotlin-9bfb640dc709" rel="noreferrer">https://medium.com/@adinugroho/unwrapping-sort-of-optional-variable-in-kotlin-9bfb640dc709</a>
<a href="https://kotlinlang.org/docs/reference/null-safety.html" rel="noreferrer">https://kotlinlang.org/docs/reference/null-safety.html</a></p>
