A

Admin • 670.22K Points
Coach

Q. What is the result of this code?

Code:
let values = [1, 2, 3]
print(values.map { $0 * 2 })
  • (A) [1, 2, 3]
  • (B) [2, 4, 6]
  • (C) [0, 2, 4]
  • (D) [1, 4, 9]
  • Correct Answer - Option(B)
  • Views: 1
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Admin
`map` applies the function to each element, doubling each value.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.