Complete the code to declare an optional String variable named name.
var name: [1]In Swift, to declare an optional String, you add a question mark after the type: String?.
Complete the code to safely unwrap the optional variable name using if let.
if let unwrappedName = [1] { print("Hello, \(unwrappedName)!") }
Use if let followed by the optional variable to unwrap it safely.
Fix the error in force unwrapping the optional age variable.
let age: Int? = 25 let unwrappedAge = [1]
To force unwrap an optional, use the exclamation mark after the variable name.
Fill both blanks to unwrap optional email and provide a default value if nil.
let email: String? = nil let userEmail = [1] ?? [2]
The nil-coalescing operator ?? unwraps the optional or uses the default value if nil.
Fill all three blanks to unwrap optional number safely and multiply by 2.
let number: Int? = 10 if let [1] = [2] { let result = [3] * 2 print(result) }
Use if let to unwrap number into safeNumber and then multiply.
