Question:

What output will be produced by the code below?

let numbers = [1, 3, 5, 7, 9]
let result = numbers.map { $0 * 10 }
print(numbers)

Correct answer: 1, 3, 5, 7, 9.

Explanation: The call to map will multiply each integer in the numbers array by 10, and assign the result to the result constant. However, the value that is printed is numbers, not result, so the original integers will be printed.


Keywords:

© 2017 QuizBucket.org