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 Swift Closures Functions as First Class Citizens Higher Order Functions

code works in playground but not Treehouse

I have the below code working in a playground but I keep getting errors when I run it via the website

func mathOperation(myfunction:(Int, Int) -> (Int), a:Int , b:Int) ->(Int) { return myfunction(a,b) }

then when I place the following code in the second part of the challenge

let difference = mathOperation(differenceBetweenNumbers,a: 3,b: 2)

I get an error message saying "Make sure your function is named mathOperation and check your parameters and return type!" . however I get no errors in xcode v. 7.2, swift 2.1.1

Marina Alenskaja
Marina Alenskaja
9,320 Points

Hi

You didn't post your code :-)

1 Answer

Hello Mark,

Throw that code up and we can give you a better idea, but when I went through the course I know I had code a few times that worked in a playground but wasnt exactly the way treehouse did it and the code wouldnt work. So it is definitely possible to have working code in a playground that isnt accepted by treehouse. Good luck!

Kind regards,

Justin