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

Trouble passing parameter to function

The challenge asked me to pass the parameter to the function and I can't figure out what I'm doing wrong. My code:

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

The error reads: Your 'greeting' printed "Hello Tom" when called with "XYXXY" as the parameter. It should have printed "Hello XYZZY".

It seems to be saying my code did what was intended but is somehow wrong. Any thoughts? The parenthesis are white, Hello is green, \ is red and person is blue

1 Answer

Hey Kurt!

Your code looks right to me, so it must be the spacing what's giving you the error.

Try this:

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

greeting("Tom")

Hope this helps!