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

Alex Lobert
Alex Lobert
2,736 Points

Hey, I can't seem to get result to have the write values. Can someone help me with the 2nd part of this challenge?

This is my code:

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

    return greeting
} 

var result = greeting("Tom")

2 Answers

Your problem is actually in the first step (1/3). I'm not sure why you were allowed to proceed to the second step. You've set greeting to return a tuple, however you're still only returning greeting, a string.

With this error, result will never hold a tuple, because because greeting will never return a tuple.

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

    return (greeting, language) //where your error occured 
}
Alex Lobert
Alex Lobert
2,736 Points

That makes sense. Thank you!