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
Thomas James
5,580 PointsHelp with tuple IOS activity.
I have just completed the Tuple IOS activity and am curious to why my code works on the treehouse environment but not the Xcode IDE.
My code is: func greeting(person: String) -> (greeting: String, language: String) { let language = "English" let greeting = "Hello (person)"
return (greeting, language)
}
var result = greeting("Tom") println(result.language)
On xcode I get the following error: Invalid redecoration of 'greeting'
What does this mean and is it a simple fix?
2 Answers
Thomas James
5,580 PointsHey thank you very much Erico. I solved it, i didn't update my IDE :)
Thank you again my friend!
Erico Souza Mendes
3,732 PointsI tried it here on my Xcode and actually, it worked!
Here's the code:
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let result = greeting("Tom")
print(result.language)
I don't know which version of Xcode you're using, mine is the 7.0 Beta 3
If you're using an precious (And not beta) version - maybe is because you are using greeting for the name of the function and for the name of the tuple and constant
Try the name of the function (or tuple, or constant) for greetings but not all in the same time.
Hope it helped. ;)
Erico Souza Mendes
3,732 PointsErico Souza Mendes
3,732 PointsGreat! I'm glad it worked :}