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 Functions as First Class Citizens

HELP!

Challenge Task 2 of 2

Assign the printer function we just created to a constant named stringPrinter. Call the function using the constant and pass in a string to print.

I am so stupid please help me!!!!

functions.swift
func printer (aString: String) {
 println("Printing the string passed in \(aString)")
}

let stringPrinter = "printer"

5 Answers

Stephen McMillan
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 Points

Hey Hamza.

With your code above your assigning the stringPrinter constant to a string. You just need to remove your quotes and then you'll be assigning it to the function!

let stringPrinter = printer

Good Luck! :)

i have tried that but still an error :/

func printer (aString: String) { println("Printing the string passed in (aString)") }

let stringPrinter = printer

above is my code

Below is the error

Bummer! Make sure you assign the printer function to a constant named stringPrinter and call the function using the constant.

Thanks a lot it worked :)