A

Admin • 670.22K Points
Coach

Q. What will this code print?

Code:
let optionalName: String? = "Swift"
if let name = optionalName {
print(name) }
  • (A) Swift
  • (B) Optional("Swift")
  • (C) name
  • (D) Error
  • Correct Answer - Option(A)
  • Views: 1
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Admin
`if let` unwraps the optional and assigns the value to `name`, which is printed.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.