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

Susant B
Susant B
1,000 Points

I do not see what is wrong in my second answer. It just say " Bummer! Your `result` variable has the wrong value in it.

I do not see what is wrong in my second answer. It just say " Bummer! Your result variable has the wrong value in it. Check the task instructions again."

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

var result = greeting("Tom")

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

var result = greeting("Tom")

1 Answer

Patrick Cooney
Patrick Cooney
12,216 Points

Why did you change the return value to include the values that were previously held in variables? Those need to remain in their variables and you need to return the values using the variables.

Susant B
Susant B
1,000 Points

Thanks Patrick for your quick answer.

But, the issue is with the order of variables. I made a minor change and it works.. which is misleading as no where instruction is given that I need to follow order for tuple.

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

I realized it when I wrote below and still it bumped.

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

let result = greeting("Tom")