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

Earnie Eng
Earnie Eng
159 Points

cannot complete first Swift function challenge even if done correctly

The error checker does not work. It warns me that I need to enclose the println function inside a function, which I did.

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

2 Answers

If this error is happening on the first task, it's probably because you've added the line to call the function afterward. The error checker can be very literal and you can get errors if you add any more code than the question asked for!

Jared Watkins
Jared Watkins
10,756 Points

Sara is right.

You have to complete the challenge tasks in order. You can't just put in the finished code on task one or else you get the error " Bummer! You shouldn't call println directly. It needs to be in the body of the function.".

This can also crash and cause the page to need to be reloaded.