Question:

When this code is executed, what will the numbers constant contain?

let numbers = [1, 2, 3].map { [$0, $0] }

 

Correct answer: [[1, 1], [2, 2], [3, 3]].

Explanation: The code loops over every number in the numbers array, and creates a new array for each number that contains that number twice. So, 1 will be converted to [1, 1] and so on.

 


Keywords:

© 2017 QuizBucket.org