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

What is wrong with my code?

I'm being told that I need to put println in the body of the function, that means within the curly braces, right? I'm not sure what i'm doing wrong here.

greeting.swift
func greeting() {

println("Hello")

}

greeting()

3 Answers

Uh? I do not think there's anything wrong w/ your code. I even tried pasting your code to the challenge and it passed.

That is so weird, I get an error message saying to put my println in the body of the function. Could there be a weird glitch?

Well, I guess you're pasting all the code into the challenge at once. What you should do is

In Step one, your code should be like this

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

And then onto the Step TWO of challenge, you add the greeting() line at the end. That should get you pass it.