Hey folks, in your opinion what is more "Kotlin Id...
# codereview
m
Hey folks, in your opinion what is more "Kotlin Idiomatic" way for guard clauses? 🤔
1️⃣ 4
2️⃣ 6
e
smart casting will only work if
keyPair
is a data class defined in the same module
(and
keyPair
is a local
val
without custom getter, etc. the usual rules for smart casting)
m
@ephemient this is not a problem for my case but good catch, I completely forgot that. 🤔
m
I would use 2️⃣ if I wanted to assign it to variable, e.g:
Copy code
val pub = keyPair.public ?: return null
val priv = keyPair.private ?: return null
otherwise 1️⃣ .
👍 3
e
the elvis operator are standard kotlin style, get used to them.
👍 2