Get the latest tech news
Omittable – Solving the Ambiguity of Null
Null values in Java are used to present both the absence of a value and the default value of a reference type variable. To design robust APIs, it is necessary to unpack this semantic ambiguity. Omittable is a library solution to this problem.
Our intention was to provide a limited mechanism for library method return types where there needed to be a clear way to represent "no result", and using null for such was overwhelmingly likely to cause errors. Effectively, Optional is a library solution to a language problem: Since the type system does not carry nullability information, it is easy to forget null checks or introduce accidental breaking changes. Incidentally, the lack of special-casing of nulls is also what enables omittable to satisfy all three monad laws.^monad-laws The proof is left as an exercise to the reader.
Or read this on Hacker News