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

Doesnt return name

func greeting(person: String) -> String { return "Hello" ; "(greeting(person))" } i supposed to get Hello Person name what us wrong with my code

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

3 Answers

William Li
William Li
Courses Plus Student 26,868 Points

Hello, hamsa mussa

Original code template:

func greeting(person: String) {
    println("Hello \(person)")

Pretty much to pass this challenge, you only need to do TWO things to Modify the given code.

  1. change the println keyword to return.
  2. give this function the return type String.

And leave everything else untouched.

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

Hope this helps.

Thank you William for your reply, This is the reply from Code Challenge Bummer! Your function isn't returning the correct value. I tried passing "Fred" as the parameter and got back "Hello", but expected "Hello Fred".

Thank You very much for your help. I Appreciate it.