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

gregd

07/14/2017, 5:25 PM
Hi all K Is there any way to disable asserted
!!
calls altogether?
d

danny

07/14/2017, 5:27 PM
Often unavoidable when you have interop with null permissive libraries and when Kotlin can’t infer non-nullability
I definitely prefer
!!
or elvis, to null safe operators
k

karelpeeters

07/14/2017, 5:31 PM
Elvis and !! are not comparable at all.
I'd even say that !! is almost never a good idea.
d

danny

07/14/2017, 5:31 PM
Failing fast on null isn’t a good idea?
1
It’s just shorthand for
?: throw ...
if you prefer elvis
k

karelpeeters

07/14/2017, 5:33 PM
Yes I know that, but if one of the parameters of your method is nullable and you're going to fail-fast anyway, you shouldn't have made that parameter nullable.
Unless there's a usecase i'm missing?
d

danny

07/14/2017, 5:33 PM
Java interop
I agree completely when you’re talking all Kotlin code, in that case nullability in your type signature is hopefully communicating a contract akin to
Optional
But when you’re interoping with Java code, all bets are off
k

karelpeeters

07/14/2017, 5:35 PM
As soon as those platform types are converted to non-nullable Kotlin types an exception is thrown automatically, no?
g

gregd

07/14/2017, 6:08 PM
I agree with @karelpeeters To be honest, I’ve never had a situation where !! would give me any advantage at all