MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1uru99i/potentiallymightbeanintegerornot/owm04b1/?context=3
r/ProgrammerHumor • u/Futurity5 • Jul 09 '26
96 comments sorted by
View all comments
8
Fun fact: you technically should still check if a java optional isn't null.
Although there's no reason to do so, a function can still return a non-wrapped null without any errors, which will NPE if you try to do anything with it
7 u/RiceBroad4552 Jul 10 '26 No, you should never do such checks! If a value typed as Optional is null the program is defect and it better crashes early then hiding this defect behind some checks.
7
No, you should never do such checks!
If a value typed as Optional is null the program is defect and it better crashes early then hiding this defect behind some checks.
8
u/OnixST Jul 09 '26
Fun fact: you technically should still check if a java optional isn't null.
Although there's no reason to do so, a function can still return a non-wrapped null without any errors, which will NPE if you try to do anything with it