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 trialWilliam Bergstein
2,078 PointsWhat is wrong with my Code?
I have tried using return(greeting,language) and I have tried using the strings instead of the constants because I told the function to return two strings. I even created a variable that consisted of the conactation of greeting and language and then tried to return that. I dont understand what I am doing wrong.
func greeting(person: String) -> (String,String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting,Language)
}
William Bergstein
2,078 PointsNo its not a capitalization thing. I just checked.
2 Answers
Dave Berning
17,365 PointsThe typo wasn't the major issue. The major issue was that you're declaring the return value to be (String,String) when it should have the constant name before each one.
func greeting(person: String) -> (language: String, greeting: String) {
let language = "English"
let greeting = "Hello \(person)"
return (language, greeting)
}
var output = greeting("Dave")
println(output) // just to see output for testing purposes
Brian Pemberton
4,902 PointsI realized this later. I forgot to come back to update my answer. Uboat to you.
Brian Pemberton
4,902 PointsI think you made a typo? You capitalized language or vise versa?
func greeting(person: String) -> (String,String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting,language)
}
Brian Pemberton
4,902 PointsBrian Pemberton
4,902 PointsI think you made a typo? You capitalized language or vise versa?