If we do our own null check (e.g., if (value != null)), the Kotlin compiler knows that the value cannot be null. Therefore, it lets us make calls that might not normally be allowed on nullable types. This "smart contract" system effectively upgrades our type from a nullable type to a non-nullable one, while we are within a code block where the compiler can guarantee that the object is not null.

You can learn more about this in:
Run Edit