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

Martin Franzner
Martin Franzner
3,300 Points

return statement

Someone could please tell me whats going wrong? Ive done exactly like in the video, but was with an Int, maybe my problem is in the String part, I dont know, if anyone could help me, I would extremely appreciate...

returns.swift
func greeting(person: String) -> String {
    return person

}
let greet = person("Tom")
println("Hello \(greet)")

2 Answers

Damien Watson
Damien Watson
27,419 Points

Hey Martin,

The "Hello" needs to be in the return String, you can cut out storing and printing it. So:

func greeting(person: String) -> String {
    return("Hello \(person)")
}
Martin Franzner
Martin Franzner
3,300 Points

Oh, now makes total sense! Thank you Damien!