Re:Java Without If
by chc on Friday January 27, 2017 @07:23PM
(#13503995)
They're called identically in the if case, but they're not used identically. One of functions isn't guaranteed to return a value, so it requires an "if x != null". flatMap basically says "this might be null." Part of the point here is that it makes it explicit when something might return null and ensures it's handled properly.
[ Parent
| on HN ]
There are no comments on this comment yet.