I've tried the following code and I got an error.
var possibleNumber = "Hello World!"
if let actualNumber: Int = Int(possibleNumber) {
print("\"\(possibleNumber)\" has an integer value of \(actualNumber)")
} else {
print("\"\(possibleNumber)\" could not be converted to an integer")
}
print(actualNumber) // **Here comes the compile time error**
Error:
use of unresolved identifier 'actualNumber'
What is happening behind the object actualNumber? I declared it in the first part of the optional binding: "if let actualNumber: Int ....." then why is it "unresolved"? hmmm... "unresolved" what is that exactly?
I guess printing a nil is somehow wrong, but why it is wrong? I don't know. Can someone explain this a bit more? and BTW is there a really a nil inside the actualNumber? If so, how can I "see" it?