First let's correct the aforementioned (bad) example
plan = customer == null ? BillingPlan.basic() : customer.getPlan();
Table 1. Representations of zero or one element lists
Our Example | Scala | Haskell |
---|---|---|
OneOrNone
|
Option
|
Maybe
|
One
|
Some
|
Just
|
None
|
None
|
Nothing
|
These representations are effectively a first-class null
over which we can write functions.