Re:Overhead of Returning Optional Values in Java and Rust
by valenterry on Saturday October 16, 2021 @09:36PM
(#28893217)
Because then you cannot differentiate anymore between "NullPointerException as a bug" or "NullPointerException as a feature".
E.g. you might want to return the streetnumber of a user's address. When a NPE is thrown, was it because there is a bug somewhere in the code or because the user's address has no street number?
With Optional, it is clear: there was no street number.
E.g. you might want to return the streetnumber of a user's address. When a NPE is thrown, was it because there is a bug somewhere in the code or because the user's address has no street number?
With Optional, it is clear: there was no street number.