https://kotlinlang.org logo
#announcements
Title
# announcements
a

alexsullivan114

09/06/2017, 3:44 PM
@barrongineer yeah, the elvis operator definitely solves part of the problem, but the thread @jw linked outlines a few more use cases. Sounds like it's normal if/else's or nested let's for now.
e

elizarov

09/06/2017, 3:55 PM
Don’t forget solutions with normal
val smth = ....
. You can also do early return. Works great when you judiciously apply “introduce function” refactoring to your code
a

alexsullivan114

09/06/2017, 3:58 PM
If you have time, would you mind elaborating on what you mean by using early return?
k

kingsley

09/06/2017, 9:47 PM
Something like this:
Copy code
val a = couldBeNull ?: return
val b = anotherNullable ?: return

// Now, a and b are not null
a

alexsullivan114

09/07/2017, 3:28 PM
@kingsley that sounds like a good answer to swifts guard,
K 1
3 Views