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