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 trial

iOS Generics in Swift Generic Functions, Parameters and Constraints CSS Background Blend Modes Challenge

generic 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.
Nathan F.
30,773 Points

To 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.

thanks, got it

Gavin Hobbs
Gavin Hobbs
5,205 Points

aaron du what was your final answer? I can't figure it out. This is my code...

func map<T, U>(array: [T], transformation: (T) -> U) -> U {
    return transformation(array)