You do have another solution that can lower the amount of conditions: Null Objects. These don’t fit every use cases, but they can allow you to express what’s missing, or not defined, or empty, and avoid nil pointers dereference or conditions to check the state.
As Sandy Metz is used to say « Nothing is Something »[0]
ramchip|2 years ago
> This is highly related to the "Null Object Pattern", but I thought I would explain it from the perspective of functions.