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

Rogelio Valdez
Rogelio Valdez
6,244 Points

You should`t call println() directly

It says I should`t call the println() directly, that it should be in the body of the function. Isn't that what I'm already doing?

I am doing this: func greeting() { println("Hello") } greeting()

greeting.swift
func greeting() {
println("Hello")
}
greeting()
Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

What you have there looks valid. Does it definitely want you to actually call the function at this stage? If you take that out does it work by any chance?

Rogelio Valdez
Rogelio Valdez
6,244 Points

You're right!! The error was that I wasn't supposed to call the function at this stage. I guess the compiler should show a different warning but it doesn't, anyway... this fixed the problem. Thank You.

1 Answer

Fuad Adetoro
seal-mask
.a{fill-rule:evenodd;}techdegree
Fuad Adetoro
iOS Development Techdegree Student 11,599 Points

Don't call the function just yet. For stage one just create the function and give it the println statement. When you get to stage two you can call the function.

Or... just comment the function greeting being called then uncomment it on stage two.