in the Swift Playground I have: "You can use a shorter spelling to unwrap a value, using the same name for that unwrapped value." then,
if let nickname {
print("Hey, (nickname)")
}
I receive "Variable binding in a condition requires an initializer" when I try to run it
2
Answers
I think you should use
if let n = nickname { Print("(n)")
Upgrade to Xcode 14.
In Xcode 14, you can write this:
and it’ll work fine because you’re using Swift 5.7. Xcode 13.x and earlier have older Swift versions which don’t work with the abbreviated unwrapping form that you’re trying to use.