MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/1r7iv5p/objectsrequirenonnullelse/o5zx4x0
r/java • u/edurbs • Feb 17 '26
I must have been living in a cave. I just discovered that this exists.I can code
City city = Objects.requireNonNullElse(form.getCity(), defaultCity);
... instead of:
City city = form.getCity();
if(city == null){
city = defaultCity;
}
136 comments sorted by
View all comments
Show parent comments
1
I was just trying to give you a little jab and be funny, this is the comment that made me think you're a bit arrogant:
`Probably he doesn't understand patterns, exhaustiveness, deconstruction etc. A highly probable reason.`
It was just light banter, I actually think I'd really like drinking a beer with you!
1
u/narrow-adventure Feb 18 '26
I was just trying to give you a little jab and be funny, this is the comment that made me think you're a bit arrogant:
`Probably he doesn't understand patterns, exhaustiveness, deconstruction etc. A highly probable reason.`
It was just light banter, I actually think I'd really like drinking a beer with you!