3 ms·
>encountering nil in your happy path is rendered harmless. Only if by "harmless", you mean "creates a bug later rather than a crash now", as compared to tradit
by happytoexplain 5y ago
>encountering nil in your happy path is rendered harmless.
Only if by "harmless", you mean "creates a bug later rather than a crash now", as compared to traditional null handling. But Optional has neither problem.
>It’s better than option primarily because it means a lot less code. You delete all “is this value present?” type code from your codebase
"It's better because it's less code" is a pretty big red flag if that's the only advantage. Especially when "less code" means `foo.bar` instead of `foo?.bar`, or `if foo.bar` instead of `if foo?.bar == true` (and even in the second example, if you're touching `foo` multiple times, you can unwrap it one time with `if let` instead).