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 trialmark lesbirel
2,012 PointsError is println should not be called directly, it should be in body of function. But it is (I think) ;-)
Error is println should not be called directly, it should be in body of function. But it is (I think) ;-) Works in playground just not on treehouse site...
func greeting() { let halo = "Hello" println("(halo)") }
greeting()
func greeting() {
let halo = "Hello"
println("\(halo)")
}
greeting()
6 Answers
William Li
Courses Plus Student 26,868 Pointswhat's the error? I see no error from this code of yours.
mark lesbirel
2,012 PointsI think it's an error in the compiler or whatever is checking the code when I do the test in a browser. It's happened before and thrown me into looking for solutions when code was ok... thx for checking ;-)
mark lesbirel
2,012 PointsOK so here's the error I get in a 'red' panel...
Bummer! You shouldn't call println
directly. It needs to be in the body of the function.
kjvswift93
13,515 PointsIt means that you are not giving the answer it expects... it is not a very helpful error message, in fact it doesn't really make sense. I think it simply means that it doesn't want another constant in the function. If you just input:
func greeting() {
println("Hello")
}
greeting()
Then you don't have any issues.
William Li
Courses Plus Student 26,868 Pointsactually, if you try copy/paste his code to challenge, it'll pass. His code got no problem at all, I think his only mistake is to copy everything over, including the last line greeting()
, which part 1 of challenge didn't expect and thus cause error.
kjvswift93
13,515 PointsThat is it. The first part of the two challenges never asks for the greeting function to be called "directly" hence the error "don't call println directly".
kjvswift93
13,515 PointsThat is it. The first part of the two challenges never asks for the greeting function to be called "directly" hence the error "don't call println directly".
mark lesbirel
2,012 PointsThanks guys, glad I was able to instantiate a conversation at least ;-)