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

I'm not sure what to do. I'm pretty sure this is the right answer... I've been stuck for awhile

challenge #2

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

var result = greeting("Tom")

Brady, can you post the Challenge question?

I was able to copy and paste your code into the challenge question and it worked for me. Can you provide more information as to what you are having issues with?

3 Answers

This is the right answer. I was able to copy and paste your code into the Challenge and it worked.

Daniel Taylor
Daniel Taylor
1,504 Points

Brady,

Here is what I used:

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

Thanks, I fixed it. It would only accept my answer after I changed the order to (greeting, language) instead of (language, greeting). Very annoying.... I wasted 45 mins trying to figure out what I did wrong. It seems like a bug because return order shouldn't matter for this exercise. Ugh.