Hi,
I am currently reading “The Nil Coalescing Operator”. There is a program as below:
import UIKit
var errorCodeString : String?
errorCodeString = “404”
var errorDescription : String?
if let theError = errorCodeString, let errorCodeInteger = Int(theError), errorCodeInteger == 404 {
errorDescription = "\(errorCodeInteger + 200) : resource was not found."
}
var upCaseErrorDescription = errorDescription?.uppercased ()
errorDescription
upCaseErrorDescription?.append(“PLEASE TRY AGAIN”)
upCaseErrorDescription
errorDescription = nil
let description: String
if let errorDescription = errorDescription {
description = errorDescription
} else {
description = “NO ERROR”
}
For this line:
if let errorDescription = errorDescription
errorDescription has been declared as variable since the beginning and declared again as constant here. I am confused here. Are these two “errorDescription” the same?
Appreciate your help. Thank you.