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 trial
jurgen meco
30 PointsHow do i have to type, I'm confused!!!!
please help., i tried many times but still don know what to type, please help.
func
greeting() {
println("Hello")
}
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! I'm not sure exactly which step you're stuck on, but I'll show my solution and then walk you through it:
func greeting(person: String) {
println("Hello \(person)")
}
Here we define a function named greeting. This function accepts a parameter named person of type String. Next we print out the line with "Hello". At this point it's going to look up the name that was sent into the person parameter and put it in that spot. So if we sent in "Jennifer", it will print out "Hello Jennifer". Hope this helps!
boris said
3,607 PointsAlso, some other helpful tips for writing better functions in the future is that they always need a name, the left slot is for the input, and the right slot is for the output. Not all functions need parameters or return types, if not, the empty parameter is an empty set of parenthesis and return type is nothing more than an opening brace after the return type. I hope this helps!
jurgen meco
30 Pointsjurgen meco
30 Pointsok thank you :)