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 trialFabian Ullrich
2,442 PointsI'm stuck in a code challenge about swift 2 closures
I have to assign the printer function to a constant and then use this constant to call the function with any string passed in. At least I understood it like this, but when I write it like down below, I get a "Bummer" message saying: "Make sure your function is assigned to a constant called 'stringPrinter'.
func printer(p: String) {
print(p)
}
let stringPrinter = printer()
stringPrinter("Hey!")
1 Answer
jcorum
71,830 PointsFabian, one small problem. When you assign a function to a constant you need to omit the parentheses, as emphasized in the video. Try this instead:
func printer(p: String) {
print(p)
}
let stringPrinter = printer
stringPrinter("Hey!")
Fabian Ullrich
2,442 PointsFabian Ullrich
2,442 PointsOh... Thank you, jcorum!