Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Michael Castro
11,959 PointsChallenge Task 1 of 1 In the editor, we're using the map function on an array of numbers to perform an operation.
What's wrong with what I've done here? I'm using a trailing closure and short hand syntax to double each value
func doubleValue(i: Int) -> Int {
return i * 2
}
let doubler = doubleValue
let doubledValues = [1,2,3,4].map() { $0 * 2 }
3 Answers

Brandon Maldonado Alonso
10,050 PointsI'm not sure if it is still useful for you, but you just have to delete the parenthesis from map like this: let doubledValues = [1,2,3,4].map { $0 * 2 }

carriebarnett
16,732 PointsThis also worked for me:
let doubledValues = [1,2,3,4] //.map(doubler)
let doubler = doubledValues.map { $0 * 2 }
func double(_ i: Int) -> Int {
return i * 2
}
print(doubler)

Mina Makar
5,421 Pointsfunc double(_ i: Int) -> Int { return i * 2 }
let array = [1,2,3,4]
let doubler = array.map { $0 * 2}