Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialaaron du
5,946 Pointsgeneric functions with multiple type parameters
i need help with this code challenge. i have been doing all i could and tried my best to pass this challenge, but my code just couldn't be compiled. help please!!!! thanks
func times4(aray: [Int]) -> [Int] {
let size = aray.count - 1
for size in aray {
aray(0...size) * aray(0...size)
}
}
func map<T,U>(array: [T], transformation: (T) -> U) -> [U] {
transformation = times4(array)
return transformation
}
1 Answer
Nathan F.
30,773 PointsTo get started, the code challenge only wants you to create a map<T,U> function with a transformation parameter. Treehouse will test the map function by supplying different arguments to transformation, so you don't need to add a times4 function or call it in your map function.
aaron du
5,946 Pointsaaron du
5,946 Pointsthanks, got it
Gavin Hobbs
5,205 PointsGavin Hobbs
5,205 Pointsaaron du what was your final answer? I can't figure it out. This is my code...