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 trialHamza Ahmad
3,061 PointsHELP!
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!!!!
func printer (aString: String) {
println("Printing the string passed in \(aString)")
}
let stringPrinter = "printer"
5 Answers
Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsHey 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! :)
Hamza Ahmad
3,061 Pointsi have tried that but still an error :/
Hamza Ahmad
3,061 Pointsfunc 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.
Stephen McMillan
iOS Development with Swift Techdegree Graduate 33,994 PointsYou forgot to 'Call the function using the constant and pass in a string to print.'
let stringPrinter = printer
printer("hello.")
Cheers.
Hamza Ahmad
3,061 PointsThanks a lot it worked :)