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

> Perhaps it's just me, but I don't equate optional with nullable.

But the main usage of Optional and similar types in mainstream languages is exactly that - making the potential nullness (is that a word?) of the value explicit in the type.



There are multiple ways to represent an optional value, for example:

1) an empty list/array 2) throw an exception if the return value is missing. 3) -1

Optional can be used as a better alternative in all these cases. It's not just null.




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

Search: