why is optional chaining required in an if let statement
- by b-ryan ca
Why would the Swift compiler expect me to write
if let addressNumber = paul.residence?.address?.buildingNumber?.toInt() {
}
instead of just writing:
if let addressNumber = paul.residence.address.buildingNumber.toInt() {
}
The compiler clearly has the static type information to handle the conditional statement for the first dereference of the…