A Swift Corner Case
Any call to a method or property that uses optional chaining will return the same type as it normally does, but wrapped in a optional. Which makes sense—any broken link in the chain will cause the whole thing to return
nil
. This is true even for methods that returnVoid
. Chained calls will returnVoid?
.[…]
Because of the combination of optional chaining and implicit return, we suddenly were left with a closure that was automatically returning something of type
Void?
, which clashed withaddOperationWithBlock()
’s expectation ofVoid
.