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

Creating a function

Hi everyone!

Please, tell me what I am doing wrong. Have a task: 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).

here is what i do:

func greeting(person: String) {
    println("Hello, \(person)")
}

greeting("D").

When I copy it to Xcode, it prints the result correctly, while the treehouse test says that there is a mistake.

2 Answers

Thanks, I figured it out. the problem was in coma after "hello". I removed a coma and it worked:)

Hello :

Everything seems to be ok, but you should pass it the name β€œTom” instead of using β€œD”.