I've got code that looks like this:
let duration = funcThatReturnsAnOptionalNSTimeInterval()
let time = duration ?? otherFuncThatReturnsNSTimeInterval()
That is giving me the error:
Binary operator '??' cannot be applied to operands of type 'NSTimeInterval?' and 'NSTimeInterval'
Ummmm.....isn't that exactly what the ??
operator can be applied to?
Am I missing something here?
Your problem is probably elsewhere. This runs just fine:
func optional() -> NSTimeInterval? {
return nil
}
func nonOptional() -> NSTimeInterval {
return 145
}
let duration = optional()
let time = duration ?? nonOptional()
print(time)
Perhaps post some more of the surrounding code?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments