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

Josh Smith
Josh Smith
1,049 Points

Don't really know whats being asked of me?

I don't get what the question is asking me to do, my guess answer is probably retarded too

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

    return (greeting, language)
}

var result = greeting("Tom")
  println(language, result)
joe lee
joe lee
844 Points

the last line should be as below

println(result.language)

5 Answers

Hi Josh, your code is fine, the only thing is that you are doing more than the challenge asked you. If you read the last sentence of the challenge instructions it says: We will print them out in the next task.. So the only thing you need to do is delete the last line of code.

Josh Smith
Josh Smith
1,049 Points

Hey Dave, thanks for helping me out again, I'm going no where fast :)

This was actually the 3rd part of the task pretty sure where it does ask you to put together the println piece at the end?

Josh Smith
Josh Smith
1,049 Points

Ah yes you are right I'm sorry. I was only on the 2nd part of the task, the 3rd bit is asking me to do this: "Using the println statement, print out the value of the language element from the result tuple."

So i've got all this which is correct but I'm getting it wrong as I'm trying to print the value of the language element from the result tuple (I don't even understand that part of the question):

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

return (greeting, language)

}

var result = greeting("Tom") println(WHAT THE F**K DO I PUT HERE)

Can someone follow up on this?

Sam Donald
Sam Donald
36,305 Points

In this instance you can think of the "." as the word "of", so...

println(result.language) as a coherent sentence would be. Print the result of language

Melc Sokat
Melc Sokat
1,310 Points

println(result.language) solve the puzzle

but why ?

why not println(result)

If i run ....

println(result.language) in my playground i get this message.

Playground execution failed: MyPlaygroundStrings.playground:13:17: error: use of unresolved identifier 'language' println (result,language)

So i think in my opinion the right answer is println(result) because result include both language and greeting !!

No need to add language... it will not work in playground.

I sit and i think the only posibility to ask us... the specify result is a method of challange.

Sam Donald
Sam Donald
36,305 Points

I noticed you have written println(result.language) but your error msg shows println(result,language)

Check your code to see that you've not used a , where you need a .

Although the challenge requires you to create a variable called result, in the println you are not calling the variable result, but rather the result (value stored in) language (i.e. English).

I'd say it was just poor naming conventions on the part of the challenge creators.

(I should say I'm a noob at iOS but this is the issue as I interpret the code.)

Melc Sokat
Melc Sokat
1,310 Points

Thanks Sam. We all are noobs here. So no offence :)