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 trialMichael McKinley
1,476 PointsWhat would be considered the function in this challenge? my code: let greeting = "Hello" println(greeting)
This code doesn't work
let greeting = "Hello"
println(greeting)
1 Answer
Daniel Sattler
4,867 PointsOk, this is pretty basic stuff though. You may have a closer look at the swift basic course:
func greeting() {
println("Hello")
}
you create a function with the key word "func" followed by the name you wanna give it. As we donΒ΄t pass anything TO that function, this name will be followed by empty brackets "()" Within "{" and "}" you write every code you want to have executed, when this function is called.
to call a function, in this case "greeting" you just do as follow:
greeting()
i hope this points you in the right direction ;-) Keep going, donΒ΄t give up