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

Anthony Rios
Anthony Rios
1,780 Points

My answer is correct for this question. Its saying its wrong and its just a simple answer. var result = greeting("Tom")

I may somehow be looking past something or reading the question wrong but it seems clear. Not sure whats wrong with it.

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

    return (language ,greeting)
}

var result = greeting("Tom")

1 Answer

Anthony Rios
Anthony Rios
1,780 Points

There is a flaw. Step one of the challenge has you modify the func. If you modify the function by making the return values (language: String, greeting: String) it passes you through step one, even though the func should be modified as (greeting: String, language: String). But then when you get to step two and try to implement the var result = greeting("Tom") it says the answer is incorrect. In a way it is but its hard to identify why without knowing to go back to the previous challenge because the part two answer is actually correct!