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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Alex Ferguson](https://uploads.teamtreehouse.com/production/profile-photos/222252/micro_KillerBee-jinchuriki-18570036-1280-720.jpg)
Alex Ferguson
2,518 PointsSwift Functions Challenge 2 of 3
The question challenge says "Modify the println statement within the greeting function to use the variable person. For example, if you pass a person named "Tom" to the function then it should display: Hello Tom. (Hint: you must use string interpolation)."
func greeting() { var person = Tom println("Hello (person)") }
what am I doing wrong here
1 Answer
![notf0und](https://secure.gravatar.com/avatar/4354b6cf0f48e58553934d07f7f1c80d?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
notf0und
11,940 PointsYou're just missing the backslash before (person)
.
\(person)
will work.
Also, you're missing your parameter in the function, though, maybe that's just on the forums.
Hope that helps.
Alex Ferguson
2,518 PointsAlex Ferguson
2,518 PointsI did that, none of these work either:
func greeting(person: String) { println("Hello (person)") } greeting(Tom)
or
func greeting() { var person = "Tom" println("Hello (person)") }
or
func greeting() { var person: String = "Tom" println("Hello (person)") }
notf0und
11,940 Pointsnotf0und
11,940 PointsOh jeez, I'm sorry, I missed another issue.
You're not supposed to assign a variable to "person", and you're not supposed to call the function. Just modify the
println
statement to include the variable "person".Your first example, minus "greeting(Tom)" will work if you include the backslash before "(person)".
You can put your code on the forums so it's displayed correctly by following this detailed post: https://teamtreehouse.com/forum/posting-code-to-the-forum
In this case, use "swift" as the language.