Single exclamation mark in Kotlin

kotlin

Solution

They're called platform types and they mean that Kotlin doesn't know whether that value can or cannot be `null` and it's up to you to decide if it's nullable or not.

In a nutshell, the problem is that any reference coming from Java may be null, and Kotlin, being null-safe by design, forced the user to null-check every Java value, or use safe calls (`?.`) or not-null assertions (`!!`). Those being very handy features in the pure Kotlin world, tend to turn into a disaster when you have to use them too often in the Kotlin/Java setting.

This is why we took a radical approach and made Kotlin’s type system more relaxed when it comes to Java interop: now references coming from Java have specially marked types -- Kotlin Blog

Problem

What does a single exclamation mark mean in Kotlin? I've seen it a few times especially when using Java APIs. But I couldn't find it in the documentation nor on StackOverflow.

Original source