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 trialSasa Djukic
1,089 PointsHow do I return a "Hello" right next to (person)?
I don't understand how to complete this challenge. I'm supposed to return a variable next to a constant but i can't seem to use string interpolation correctly.
The answer is not: return ("Hello (person)") (NOTE: the editor doesn't show the backslash before (person))
Please help
func greeting(person: String) {
return greeting
}
3 Answers
Roberto Alicata
Courses Plus Student 39,959 PointsFirst you have to define the return type adding "-> String" after the parameters of the function
func greeting(person: String) -> String {
println("Hello \(person)")
}
then you need to replace the println function with a return statement
func greeting(person: String) -> String {
return "Hello \(person)"
}
Wes Laing
3,497 Pointsfunc greeting(person: String) -> String { println("Hello \(person)") return "Hello \(person)" }
Sasa Djukic
1,089 PointsThank you Wes and Roberto. I forgot about '-> String'