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 trialMatt Brown
7,782 PointsTuples Objective Question - What is wrong with my code?
https://www.dropbox.com/s/0kfr4d88e2y5bho/Screenshot%202015-01-05%2021.32.26.png?dl=0
Link above is a screenshot of my error
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)}
var result = greeting("Tom")
1 Answer
Stone Preston
42,016 Pointstask 1 states: Make sure to name each item in the tuple: greeting and language
Its not entirely clear but greeting needs to be the first element in the tuple and language second. change your return type and the return tuple around. also be sure that you close the function after the return and the the result constant is created outside of the function scope
// change the return type so that greeting is first, and language second
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
// make the greeting the first element, and language second
var greeting = ("Hello \(person)", language )
return greeting
} //close the function
let result = greeting("Tom")
Matt Brown
7,782 PointsMatt Brown
7,782 PointsWow another speedy response - thanks so much and love the service and help! Would be nice if they specified the order needed. It was working in x-code fine for me so that's why I was pretty confused :)