Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If it is a requirement for something not to be null, unwrap the option before you send to it to the part of the program that can't accept nulls, and deal with the case of None in a sane way and in a predetermined place. Then you don't have to worry about unwrapping in the rest of the code. You can escape from Option. It's not like IO. You just have to check for None if you want to get something out, as you should.

In this fashion, you have type safety everywhere, and you deal with the case of a missing value in a predictible way, in a single spot.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: