Hi all :kotlin: Is there any way to disable assert...
# announcements
g
Hi all K Is there any way to disable asserted
!!
calls altogether?
d
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
Elvis and !! are not comparable at all.
I'd even say that !! is almost never a good idea.
d
Failing fast on null isn’t a good idea?
1
It’s just shorthand for
?: throw ...
if you prefer elvis
k
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
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
As soon as those platform types are converted to non-nullable Kotlin types an exception is thrown automatically, no?
g
I agree with @karelpeeters To be honest, I’ve never had a situation where !! would give me any advantage at all