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 Functions and Optionals (Challenge Task 2 of 3)

This is my code for the Challenge Task 2 of 3:

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

But I am getting this error message:

Bummer! Your greeting printed "Hello Tom" when called with "XYZZY" as the parameter. It should have printed "Hello XYZZY".

This is working in Xcode. Any ideas?

3 Answers

You need to remove the greeting("Tom").

That part is not asked for until part 3.

Hi Adam,

Try the challenge again as I just copy and pasted your code in and it worked as expected, sometimes the challenge can glitch in which waiting a minute or two then refreshing resolves the issue.

Thanks Logan,

That solution worked. I didn't realize the next step asked for that next line of code.

No problem!

If you have any more questions, feel free to post them.