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 trialbrett phares
1,314 PointsFunction task challenge works in Xcode but not in treehouse editor window
The following works in Xcode but returns this error in treehouse editor, "Bummer! You shouldn't call println
directly. It needs to be in the body of the function."
func greeting() { println ("Hello") }
greeting()
Seems valid, println is inside the function (isn't it?), not sure how to troubleshoot.
3 Answers
Logan R
22,989 PointsThat is very weird. I tried your code and it worked just fine for me.
The only thing I can suggest is make sure you are not calling greeting()
in the first task, only have the function being defined. Wait until task to to include greeting()
.
Peter O'Brien
9,348 PointsHi, I'm having the same problem with this code. It works fine in Xcode, but is failing with the same error message as the original poster.
I'm running in Safari if that helps.
func greeting() {
let hi = "Hello"
println(hi)
}
greeting()
Thanks, Pete
Logan R
22,989 PointsTry it without the constant
func greeting() {
println("Hello")
}
Peter O'Brien
9,348 PointsThanks, Logan. It worked with and without the content once I dropped the function call during step 1. I'd completely misread the question and tried to complete the whole challenge in one step. Normally, the challenge editor would just move onto the next step, but sorted now. Thanks.
Logan R
22,989 PointsNo problem.
The code editor did use to do that, but I bet they have changed that to stop people from just pasting in the code answers.