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

Stuck on this Challenge Question

For this challenge question, here is the code I am inputing:

func greeting(person: String) -> String { let person = "Tom" return person }

let person = greeting("Tom") println("Hello (person)")

The error message I receive is that this does not allow for different names to be passed through (i.e. Fred instead of Tom).

Can anybody provide some guidance?

Can you provide me with the link to that challenge please ?

1 Answer

Hi, while using let person = "Tom" you are defining a constant (let), in your case you might want to use var instead of let or better not use extra line and return just the greeting with string interpolation:

func greeting(person: String) -> String {
    return "Hello \(person)"
}

Hey Stepan, changing it to var and the suggested code did not work. Any other thoughts?

It actually did. I made a small error in what I wrote. Thank you so much for your help.