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

iOS Swift Functions and Optionals Functions Creating a Function

I don't know what they are asking me.

I am unsure of what they are asking of me.

This was my best attempt.

greeting.swift
func greeting()  {
let Hello = "Hello"
println("Hello")
call("greeting")
}

2 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

Hello:

The challenge wants you to create a function named "greeting", that has an output of a println that says "Hello".

func greeting(){
println("Hello")
}

And then they ask you to call the function:

// When calling the function just basically mean, using the function without the "func" part. 
greeting()

Good luck

Josue Gisber
PLUS
Josue Gisber
Courses Plus Student 9,332 Points

On the first part of the challenge they ask you to declare a function named greeting and inside the function write a println function that output "Hello". that's all, you don't have to do anything else.

Them on the second part of the challenge they ask you to call the function. Remember that to call or invoque the function you just have to write the function name, in this case: "greeting()", follow by the two round brackets "()" or parenthesis as you see. You don't have to write call. And once you do that the function will printout "hello". I suggest you to do it in playground first and check out the result them past your code in the challenge page.

Hope this clear things out for you!