I\'m using map() function of array in for-in loop like this:
map()
let numbers = [2, 4, 6, 8, 10] for doubled in numbers.map { $0 * 2 } // compile error
The syntax is ambiguous (see dasblinkenlight's answer). For an alternative syntax:
let numbers = [2, 4, 6, 8, 10] numbers.map { $0 * 2 }.forEach { print(doubled) }
or
let numbers = [2, 4, 6, 8, 10] let doubledNumbers = numbers.map { $0 * 2 } for doubled in doubledNumbers { print(doubled) }