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 trialjurgen meco
30 PointsCall the function greeting and pass it the string "Tom"
i don't know what to do, PLEASE someone help me!
func greeting ("Tom") {
println("Hello \(Tom)")
}
1 Answer
Adam Robinson
1,855 PointsWhat you need to do is you need to give the function a named parameter. it's a template for data that is entered into the funciton.
func greeting(name: String) {
println("Hello \(name)")
}
so then when you envoke the function, you pass it a name that will be represented by the variable name inside your function like so
greeting("Tom")
Hope this helps.
jurgen meco
30 Pointsjurgen meco
30 Pointsthank you, i finally understand it now, thanks :)
jurgen meco
30 Pointsjurgen meco
30 Pointsjust 1 question, where do i put "greeting("Tom")"?
Adam Robinson
1,855 PointsAdam Robinson
1,855 PointsSo you are defining a function that you want to use by calling
greeting("Tom")
so you would want to add that line of code after you define the function outside of the braces like so.