I wonder if there is any recommendation to use `==...
# codingconventions
d
I wonder if there is any recommendation to use
==
vs
?:
in order to operate with
Boolean?
. I generally try to avoid
@Nullable
types, but sometimes they are inevitable. I find more ‘natural’
Copy code
value == false
Over
Copy code
value ?: false
It seems more explicit and also easier to understand by developers new to Kotlin. Do you have any recommendations?
2️⃣ 3
1️⃣ 9
k
See https://kotlinlang.slack.com/archives/C0922A726/p1572347452220800?thread_ts=1572347452.220800&cid=C0922A726 for yesterday's discussion about this. The official standard says to use
==
.
👍 2
e
for the topic started example 2 is easier to read (evaluate) for me
the first makes me always think what is result of null == false
but maybe because I’m not used to this construction
g
== is recommended by official Kotlin style guide
👍 1
d