|
|
|
|
|
by airless_bar
3669 days ago
|
|
Not really. The main strength of the first approach is that Option is only one type out of many error-handling structures. Not every error is handled appropriately by Option/?. If you have a language like Kotlin where they hard-coded one way of handling errors, it feels very unidiomatic to pick a better fitting error handling type, while in languages where errors are handled by library code, it's a very natural approach. |
|
Which is expected since these two constructs are not aimed at handling errors: they manage missing values.
> If you have a language like Kotlin where they hard-coded one way of handling errors
No, no. `?` is not for handling errors.
Kotlin is as agnostic as Scala for managing errors: you are free to use exceptions, dumb return values or smarter ones (`Either`, `\/`, `Try`, ...).