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 Tuples

Luis Cunha
Luis Cunha
2,720 Points

I'm sure the code is correct, and yet the grader does not accept it.

...

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

    return (greeting, language)
}

3 Answers

Jhoan Arango
Jhoan Arango
14,575 Points

You are forgetting to name your tuple parameters..

Enrique Munguía
Enrique Munguía
14,311 Points

You must specify the names of the parameters in the return type

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

    return (greeting, language)
}

This is a requirement when you return tuples.

Luis Cunha
Luis Cunha
2,720 Points

Thanks. I don't think it is a requirement though (besides this exercise). This is acceptable in xcode:

func greeting(person: String) -> (String, String) { let language = "English" let greeting = "Hello (person)" return (greeting, language) }

Luis Cunha
Luis Cunha
2,720 Points

Thank you. Indeed I did not fully read the question.

Enrique Munguía
Enrique Munguía
14,311 Points

Help other students reading this question upvoting and marking the best answer.