A

Admin • 828.03K Points
Coach

Q. What is the output of the following code?

Code:
let list = [1, 2, 3, 4, 5]
print(list.first)
  • (A) 1
  • (B) [1]
  • (C) Optional(1)
  • (D) Error
  • Correct Answer - Option(C)
  • Views: 10
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Admin
`first` returns an optional containing the first element, hence `Optional(1)`.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.