``` when (obj) { null -> println("is null")...
# announcements
f
Copy code
when (obj) {
    null -> println("is null")
    else -> println("is not null")
}
I couldn't figure out how to check for not null instead.. is that possible? like
!null ->
😄
k
If you have to use when:
Copy code
when {
  obj == null -> println("is null")
  obj != null -> println("is not null")
}
Otherwise, it might be better to simply use
if (obj != null)
or perhaps, the null coalescing operator
?.
, depending on your use-case
f
Thanks!
👍 1