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 trialayman abdallah
787 PointsHelp function return problems
func greeting(person: String) {
println("Hello \(person)")
}
2 Answers
Ben Griffith
5,808 PointsHey, so the first thing you need to do is to declare the return type.
This is done by adding -> String to your function declaration. You also need to replace the println statement with a return (since you want to return this string, instead of printing it).
You're also missing a \ infron of (person) so your string interpolation won't work correctly.
This is what your code should look like once you're made those changes.
func greeting(person: String) -> String {
return "Hello \(person)"
}
ayman abdallah
787 Pointsdon't now how to do it... Anybody please explain this