Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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"))