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 Capturing Variables

Adrian Yeow
Adrian Yeow
13,866 Points

returning functions

I couldn't understand this concept func printerFunction() -> (Int) -> () { }

I have understood that the printerFunction takes no parameter and the printerFunction return's type is both Int and Void. Correct me if I am wrong. How can it return both Int and Void? Is this function similar to the other function mentioned below?

func someFunction(number: Int) -> () { } which takes in parameter which is of type Int and return Void.

1 Answer

I gave an answer to your other question, which is similar in nature, here: https://teamtreehouse.com/forum/return-void

So, basically, printerFunction takes no parameter, true, but does not return both Int and and Void. It returns a function that takes one parameter of type Int and that returns a value of type Void.