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

Miguel Correia
Miguel Correia
1,216 Points

i alredy printed hello but i think the program must be having a bug or something

i said all

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

1 Answer

Hi there,

There have been a few issues with the compiler today where it is saying code is oncorrect when it, in fact, isn't.

One way round this is to make the code deliberately fail first - remove a bracket, or something. Then, correct the code and the compiler passes the test.

Strange, I know, but it is an intermittent issue.

Your code can be amended to:

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

greeting()

I had to enter that a few times to get it to pass.

Steve.