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 trialPaula Samuels
1,853 PointsHaving trouble with the Swift Functions & Optionals challenge
Challenge: 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.
Question: I'm confused because this appears to be asking for a function named greeting that also has an argument named greeting. How do I distinguish between the function "greeting" and the argument "greeting"?
2 Answers
Petar Popovic
Courses Plus Student 23,421 PointsHi Paula, this is the solution of that task. Cheers
func greeting(person: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
Ryan Halperin
1,974 Pointsfunc greeting(person: String) -> String { return ("Hello (person)") }
// This worked for me.
Ryan Halperin
1,974 PointsNote that my post was automatically formatted to eliminate the enter and tabbing that I used for readability. Maybe something Treehouse should look at.