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

kevin nadjarian
kevin nadjarian
1,498 Points

Return function and string

Not sure I got it

Tyler Simko
Tyler Simko
5,610 Points

Hey Kevin,

Hopefully I can help - what's your question?

kevin nadjarian
kevin nadjarian
1,498 Points

Hi Tayler, thanks,

I just cannot get the code correct with a string :

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

println("hello (greeting("tom"))")

the result is "hello (Function)" and not hello tom

3 Answers

kevin nadjarian
kevin nadjarian
1,498 Points

Yes that what I did too sorry but I cannot get still have an issue

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

println("hello (greeting("tom"))")

I also try with

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

println("hello (greeting(tom))")

And also try

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

println("hello (greeting(tom))")

Can some one give me the correct answer for this exercices "Function return type" in Swift Functions and Optionals courses

Thank you

Jeremy Hayden
Jeremy Hayden
1,740 Points

You forgot the / for string interpolation. "Hello /(greeting...

kevin nadjarian
kevin nadjarian
1,498 Points

The solution was like this, finded my answer.

func greeting(#personName: String) -> String { let greetings = "Hello, " + personName + "!" return greetings }

println(greeting(personName: "Kevin"))