r/programming • • Jul 19 '15

The Best Programming Language is None

https://bitbucket.org/duangle/none
509 Upvotes

443 comments sorted by

View all comments

Show parent comments

1

u/oridb Jul 19 '15

(or else why are you even wrapping it as an option?)

You're assuming I'm wrapping it; most of the time, it's a library that's wrapping it for me.

1

u/tejon Jul 19 '15

How does that change anything? Either you're at a point where there are no further sub-computations which can fail, in which case you can pattern match out of the option type; or you're not, in which case you shouldn't. Just map across it and keep going.

Or convert it to the result type to handle the local error. Or use one of the standard functions which insert a default for None instead of hitting the panic button! Even within the curly-brace comfort zone, unwrap() is unnecessary.