4 ms·
The idiomatic way to use optional types is pattern matching (e.g. when in kotlin, switch in Swift). These pattern matching constructs tend to have a requirement
by ajanuary 8y ago
The idiomatic way to use optional types is pattern matching (e.g. when in kotlin, switch in Swift). These pattern matching constructs tend to have a requirement that your cases are exhaustive. This makes it impossible to miss the None case.
However, they also tend to provide escape hatches for getting at the type directly, which defeats that and will still let you NPE.