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 Leo
1,007 PointsIm trying to pass in a String "Tom" To have a return String say "Hello Tom"
I know i almost got it but i cant seem to figure out that 1 step im missing.
Thanks,
func greeting(person: String) -> String {
return "Hello" + person
}
greeting ("Tom")
1 Answer
Greg Kaleka
39,021 PointsHey Marco,
You've got it, you're just not doing anything with the returned value. You want to either print it, or store it in a variable, or both.
func greeting(person: String) -> String {
return "Hello " + person // I added a space here
}
var result = greeting("Tom") // I removed the space in the function call here
println(result) // this will output "Hello Tom"
Marco Leo
1,007 PointsMarco Leo
1,007 PointsHey Greg,
I'm sorry but i don't get what you mean by add a space on my return, i did it and its not working.
Greg Kaleka
39,021 PointsGreg Kaleka
39,021 PointsHey Marco - I edited my code to add the space in myself. Also, you have an extra space in your function call. I think that might cause a problem.
Marco Leo
1,007 PointsMarco Leo
1,007 PointsThanks Greg, finally got it.