We look at nullable types in Kotlin as a contract: what
String
? really means, when a safe call
?. and the Elvis operator
?: are the norm at the system boundary (input, parsing, lookup), and when
null starts to “leak” into business logic. Using examples with
toIntOrNull(), lookup in a
Map, and a mini app
ExpenseTracker, we learn to localize nullable usage and avoid anti-patterns like
!! and sentinels (
0,
-
1,
"UNKNOWN").