it’s quite often I need to perform some action onl...
# getting-started
d
it’s quite often I need to perform some action only when some property of the class is not null. Like this:
Copy code
if (this.prop != null)
        someMethod(this.prop)
Yep I’m agree that the smart cast here is not possible, so the simplest solution is to use a local variable:
Copy code
val prop = this.prop
    if (prop != null)
        someMethod(prop)
Is there more elegant way to solve this? Swift has «if let prop = self.prop» check, maybe I missed something in Kotlin? simple smile