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 trial

iOS Functions in Swift Functions in Swift Basic Function Syntax

IOS simple function syntax

I'm not sure what i am doing wrong

functions.swift
// Enter your code below

let greeting = Hello

func greeting() {
  print(Hello)
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hey Tywan,

You're on the right track, but there are things.

First off, the challenge didn't ask you to declare a constant, which you have made one called greeting. So, that will need to be deleted. Just to touch on something here, though, if you were to have to had to declare a constant, you'd want to put the string "Hello" as its value. Right now, the constant is holding another variable? that is named Hello.

Now, your syntax for the function is correct, except you are passing in that 'imaginary' variable Hello into the print method. You'll need to pass in the String "Hello".

Other than that, it's looking good. I do, however, recommend reviewing functions and types before moving on. You'll need a fairly strong understanding of these (and others) before moving on. Sometimes I need to watch a video a few times to make sure I fully grasp the concepts.

Keep Coding! :) :dizzy: