Yes, it's a contract for return types. That's about it. If used liberally, for example for parameters, it pollutes the api, and it still doesn't stop you from passing null to functions. It's simply insufficient. I'd encourage you to take a look at Kotlin null safety. You will quickly see how Optional is inferior.
View all comments
Show parent comment
3
u/marvk Jun 12 '24
Yes, it's a contract for return types. That's about it. If used liberally, for example for parameters, it pollutes the api, and it still doesn't stop you from passing null to functions. It's simply insufficient. I'd encourage you to take a look at Kotlin null safety. You will quickly see how Optional is inferior.