This code worked very well in Swift 2.3, and I don’t understand why I need to expand TestClassto check if the number is greater than 4. This is a whole point of options binding to save an extra call.
Now, to do this job, I have to check if there is testClass != nil(or use implicit expansion using the operator if let), and then check the quantity.
Is this really the only way?
import UIKit
class testClass
{
var optionalInt:Int?
}
var test:testClass?
if test?.optionalInt > 4
{
}
source
share