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 trialjurgen meco
30 Pointsi have a problem with functions, please help
this is my code, println ("Hello") func (greeting)
please help :(
println (" Hello" )
func \(greeting)
1 Answer
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsA few things:
- reverse the order of the two lines - so you start with the keyword func declaring the function
- you don't need a backslash
- greeting shouldn't be inside the parentheses, the parentheses go after it like this: greeting()
- then you need a set of curly braces { }
- inside those curley braces is where you put the things that the function does: in this case printing out "Hello"
- there should be no space between println and the parentheses: println("Hello")
- make sure there are no extra spaces inside the parentheses or inside the quotes. Both the Swift language and this particular challenge are picky.
So the whole code would look like this:
func greeting() {
println("Hello")
}