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 trialJan Francírek
1,766 PointsPlease help me with this exercise.
I understood everything what Amit said, but I dont know what am I missing in this exercise. I´ve tried let greeting = "Hello (person)" + language or I tried simply return greeting + language but its wrong... I havent done anything with string because there is only text so I do not have to neither I havent written #person because I dont need person person:String in my opinion.... So I simply dont understand this question....
Currently our greeting function only returns a single value. Modify it to return both the greeting and the language as a tuple. Make sure to name each item in the tuple: greeting and language. We will print them out in the next task.
Thank you for help
func greeting(person: String) -> String {
let language = "English"
let greeting = "Hello \(person)"
return greeting
}
4 Answers
Daniel Johnson
104,132 PointsI just helped someone with this same challenge yesterday. I think some of the videos in the course may need to be updated. They don't seem to be very clear.
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let result = greeting("Tom")
println(result.language)
Vittorio Somaschini
33,371 PointsHello Jan, here you need to do 2 things, first make sure the function return the tuple with 2 values, instead just one as it is currently defined, so:
func greeting(person: String) -> (greeting: String, language: String)
second thing to do is to return both values in the tuple, instead of only greeting.:
return (greeting, language)
So final code would be for task 1/3:
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
Jan Francírek
1,766 PointsThank you both of you for a good answer :)) cant do two best answers suddenly.
Jan
Jan Francírek
1,766 PointsBy the way... Why is in that video -> (found: Bool, description: String) and return only found ?? and in this exercise I had on the same play String: language and String: greeting also in the Return(greeting, language)
I dont see any sense there...
Thank you