Say I have the following code:
var aString: String!
aString = "second"
print(aString)
This will print out some("second")
. If I remove the !
from String
this will just print out second
. This addition of some(...)
never used to happen in Swift 4, why is this suddenly happening now in 4.1? Is there ever a reason that I'd need to keep it as String!
instead of String
now?
EDIT
Just found a reason to keep the exclamation mark - if I have an if clause without an else, my code won't necessarily know that its been unwrapped. How do I handle this situation:
var aString: Int!
let aBool = true
if aBool {
aString = 2
}
print(aString) // Prints some(2), crashes if I remove the `!`