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

sina rahmaniyehaneh
PLUS
sina rahmaniyehaneh
Courses Plus Student 1,250 Points

I have a question

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

returns.swift
func greeting(person: String) -> String {
    return person
}
println("Hello \(greeting(Fred))")

1 Answer

J.D. Sandifer
J.D. Sandifer
18,813 Points

Looks like you're missing parentheses around Fred in your function call. Additionally, the function greeting returns a String so you can't use string interpolation to insert it into the string you print out. Instead, you need to use string concatenation (string addition).

This should fix the code:

println("Hello " + greeting("Fred"))

However, I don't remember string concatenation being taught before that lesson. I think you might also want to check that you're doing exactly what the exercise asks.

If this code doesn't complete the challenge, please paste the text of the challenge directions so I can help you compare your answer to that.