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 trialGrzegorz Chyb
1,568 Points"You shouldn't call println directly, it should be in the body of function" problem
So I'm doing everything like in video: creating a function called greeting creating a constant that is a statement of Hello creating a println line, which will print the statement closing the function and executing it
Yet it still says that println has to be in the function. So it is not? Everything works like a charm in Xcode (except the println which has to be changed to print).
Please help me so I could move to next challenges. Cheers Grzegorz
func greeting() {
var statement = "Hello"
println("\(statement)")
}
greeting()
3 Answers
Andrew Taylor
11,500 PointsSorry I have it now, found out I could view the challenge. This is the correct answer judging from the challenge it directed me to.
func greeting(){
println("Hello")
}
greeting()
You don't need to create a variable to store the word hello, it just asks you to print it out using println and then call the function. Hope this helps.
Andrew Taylor
11,500 PointsTry just doing println(statement) rather than the concatenation
Grzegorz Chyb
1,568 PointsThanks for help! Problem solved, i did what you said + haven't executed the function (which was another task).
Grzegorz Chyb
1,568 PointsGrzegorz Chyb
1,568 PointsOh and I was just messing with constant and variable, but in my code there is let instead of var. But it doesn't mater in this case, right?