A

Admin • 670.22K Points
Coach

Q. What will this code print?

Code:
let str: String? = nil
print(str ?? "Default")
  • (A) nil
  • (B) Optional(nil)
  • (C) Default
  • (D) Error
  • Correct Answer - Option(C)
  • Views: 1
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Admin
`??` provides a default value when the optional is nil.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.