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

The authors of Optional intended it to only be used as a return type for library functions, to avoid well-known headaches around documenting the nullability of these functions [1].

To quote:

> For example, you probably should never use it for something that returns an array of results, or a list of results; instead return an empty array or list. You should almost never use it as a field of something or a method parameter.

[1]: https://stackoverflow.com/questions/26327957/should-java-8-g...



I think we're in agreement. This is exactly how optional should be used.




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

Search: