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

Chris Euell
Chris Euell
1,057 Points

Tuples

This challenge is over the top ambiguous, both in task and response. Been through the tuples videos twice and, since the example in the vids is so different than the challenge, I'm struggling to draw a correlation to what I'm missing. Any help is greatly appreciated.

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

    return greeting (greeting, language)
}
Felix Ayala
Felix Ayala
5,541 Points

You must return it referred by name as the challenge request: <br/> <br/>

// Make sure to name each item in the tuple greeting and language (in the return part)
// Like this: (greeting: String, language: String)
func greeting(person: String, language: String) -> (greeting: String, language: String) {
    let language = "English"
    let greeting = ("Hello \(person)")

    return (greeting, language) // remove the extra word 'greeting'
}

2 Answers

Felix Ayala
Felix Ayala
5,541 Points

Don't worry Chris, it's totally normal when you start programming in Swift.

In order to enhance your knowledge I highly recommend you to read this Apple Book called Swift Programming Language 2.1. It will help you to understand the basics along this course.

Hope it helps!

Regards.

Chris Euell
Chris Euell
1,057 Points

Yes, I've got it! Was hoping to postpone becoming absorbed in that until after these tutorials, but I take your advice in the spirit it was offered - there is no one-size-fits all panacea! I'm on it! Thanks again.

Chris Euell
Chris Euell
1,057 Points

Thanks Felix. Part of my confusion stemmed from executing the return as -> (String, String) in my own playground (v7.1.1), without error. I'm still trying to get my head around what the Treehouse Team deems critical to challenge response detail, while reconciling that with what shows up in my own playground when I test the code first. Some of this stuff is dated too (e.g. println()), and some is nonessential, if perhaps standards biased.