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

functions and println

functions

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

2 Answers

Hi Joylyne,

You're doing great, and your code is really close to working.

It's worth taking another look at the Creating a Function video. Amit does a great job explaining both how to create a function and then how to call it.

Cheers

You are extremely close!

To start, I will just let you know the syntax of a function in swift to start.

//EXAMPLE OF A FUNCTION


func functionName() {
 // Whatever the function does

}

Obviously, you'd use a different name for the function. Now really think about how you would build it for the code challenge before you read the answer below...

//ANSWER


func greeting() {

      println("Hello")

}