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

help , I think I am right but system says I´m wrong

help

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

2 Answers

First, you need to add a return type, and second, you need to turn the print statement into a return statement:

func greeting(person: String) -> String {
    return "Hello \(person)"
}

P.S., you weren't asked to call the function, but you did, and did it correctly. Usually, though, you would want to do something with the return value. E.g., store it in a variable or constant, or display it:

let msg = greeting("Tom")
print(greeting("Tom"))