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 Swift Functions and Optionals Functions Function Return Types

Paul Papagiannis
Paul Papagiannis
1,846 Points

func greeting(person: String) { println("Hello \greeting(person:String)") } hmm.. Errors...

not sure what I am doing wrong here.

returns.swift
func greeting(person: String) {
    println("Hello \(greeting(person:String))")
}

1 Answer

First, to tell a function to return a specific type, use an arrow (->) followed by the desired type. Next, the challenge wants you get rid of the println statement and replace it with return statement. If you specify that your function will return a certain type (which the challenge wants) you have to use a return statement inside that function that will return a value matching the one you specified above.

Here's a template of sorts that should help.

func functionName(parameter: parameterType) -> returnType{
    return ""
}