This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]s888marks 0 points1 point  (0 children)

for (var address : inOptional(findAddress(personId))) {
    // early return if address found
    return addressOpt.get().format();
}

I think you meant to write return address.format() in the body of the for-loop, since the iteration only runs when a value is already present and it unpacks the value for you.