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

Bryan Bastida
Bryan Bastida
1,861 Points

i'm having an issue with the tuples challenge problem

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

    let item = (language, greeting)

    return item
}
var result = greeting("Tom")

Swift

Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)

Bummer! Your result variable has the wrong value in it. Check the task instructions again.

2 Answers

Hey Bryan,

The order of your tuple is incorrect. greeting comes before language like this:

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

    let item = (greeting, language)

    return item
}
var result = greeting("Tom")
Bryan Bastida
Bryan Bastida
1,861 Points

huh, as simple as that. thank you very much. that worked

No problem. Usually, the order of that tuple would be up to you. It's just that, in this case, the challenge wanted a specific answer but wasn't very clear about it. I've noticed this happens every now and again with the Challenge tasks.

Kevin Rosario
Kevin Rosario
2,655 Points

This code seems to work. Whats the issue exactly? Are you written the word Swift at the beginning of your code? If thats the case, swift is expecting a module that doesn't exist, so all you have to do is delete the word swift.

Bryan Bastida
Bryan Bastida
1,861 Points

no, i just added that there to specify the language im using. i'll remove it and put it at the bottom. but i know the code works cause i put it in Xcode and i dont get any errors. but apparently when i hit the check work button it tells me that the result variable has the wrong value in it, which clearly it doesnt since the challenge is telling me to type "Tom". im guessing it's a bug?