Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ihosvany Diaz
2,946 PointsChallenge task 1 of 1 Modify the definition of the function named greeting to return a String and replace the println st
Hi everyone, I'm staking o this challenge and really don understand what do I have to do here is the function:
func greeting(person: String) {
println("Hello \(person)")
}
Thank
3 Answers

Chris Shaw
26,662 PointsHi Ihosvany,
The challenge is simply asking for you to remove the println
function and replace with with a return
statement then assign the return type as a String
, all of this was covered off in the previous video so I recommend you watch over it again just in case you missed anything the first time round.
func greeting(person: String) -> String {
return "Hello \(person)"
}

Ricardo Hill-Henry
38,442 PointsRemember, to make a function return a specific value you use the arrow following argument assignments. Next, get rid of println(). The challenge wants what println() was returning to be returned by the function as a obtainabe value.
func greeting(person: String) -> String {
return "Hello \(person)";
}
So now if I wanted, I can create a variable to hold the value returned by my greeting function:
var myFriendliness = greeting("Ihosvany Diaz");
myFriendliness //will return "Hello Ihosvany Diaz"

Ihosvany Diaz
2,946 PointsThank so much Chris Upjohn and cuckoo for your help this is the last challenge before complete the course