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 trialDonda Kai
754 PointsHow do i solve this?
hi
func greeting(person: String) {
return ("Hello \(person)")
}
4 Answers
Steve Hunter
57,712 PointsHi there,
To make the method return something, you need to add a ->
to the declaration. That also states what is being returned, so that's -> String
in this case.
Then you need to use the return
keyword to make that happen inside the code:
func greeting(person: String) -> String {
return "Hello \(person)"
}
Hope that makes sense.
Steve.
Donda Kai
754 PointsThat didn't help at all! It's just saying bummer
Donda Kai
754 PointsThanks anyways
Pasan Premaratne
Treehouse TeacherIf you're returning ("Hello (person)"), i.e, you're wrapping the string in parentheses, then you're returning a tuple containing a String, and not a String. Remove the parentheses to return a String.
Steve Hunter
57,712 PointsWorks fine for me - have you copied the code exactly? I've just redone the challenge a number of times to check. If you could paste me a screenshot of that code failing the challenge that would be great - there may be something amiss with the system.
Steve.
func greeting(person: String) -> String {
return "Hello \(person)"
}