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 Parameters and Tuples Named Parameters

I am totally stumped..

I cannot get past this challenge.

"Challenge Task 1 of 2 Modify the existing greeting function to have an external parameter named person."

No matter how I modify this code, I keep getting the exact same error message. Can somebody please help me with the correct code here? As well as explaining this in a way someone who has been coding for 2 days can understand it?

Thanks a million!

named_parameters.swift
func greeting(person: String) -> (greeting: String, language: String) {
    let greeting = "Hello \(person)"

    return (greeting)
}

3 Answers

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

You only have to put in # before person. You dont have to make a tuple, like you do. :-)

It worked! Thanks so much man. I still have no idea why I don't have to add "->String".. guess I will trust the process :)

You are going to use tuples later, in the challenges. You're welcome :-)

I was just overthinking it haha. I understand now, thankfully!