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 trialMarco Garduño
1,549 Pointshelp , I think I am right but system says I´m wrong
help
func greeting(person: String) {
println("Hello \(person)")
}
greeting("Tom")
2 Answers
jcorum
71,830 PointsFirst, you need to add a return type, and second, you need to turn the print statement into a return statement:
func greeting(person: String) -> String {
return "Hello \(person)"
}
jcorum
71,830 PointsP.S., you weren't asked to call the function, but you did, and did it correctly. Usually, though, you would want to do something with the return value. E.g., store it in a variable or constant, or display it:
let msg = greeting("Tom")
print(greeting("Tom"))