1 Replies - 664 Views - Last Post: 19 March 2015 - 02:39 PM

#1 WildPants   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-March 15

[Swift: Functions and Optionals] Need some simple Tuples Help

Posted 19 March 2015 - 02:29 PM

Hey guys I'm learning Swift through TeamTreehouse but I was wondering if I could get some help with this little challenge I'm stuck on.

The task is stated as this "Create a variable named result and assign it the tuple returned from function greeting. (Note: pass the string "Tom" to the greeting function.)"

This is my current code below the last little declaration of result is where the problem is. I do not get any build errors in Xcode but the treehouse is saying "Your `result` variable has the wrong value in it."

 func greeting(#person: String) -> (language: String, greeting: String) {
    let language = "English"
    let greeting = "Hello \(person)"

    return (language, greeting)
}

var result = greeting(person: "Tom")



I've tried all kinds of different stuff, & referred to the swift docs before posting but none of them have worked so I figured it was time to try to get some help on this. haha It's probably simple as hell but thanks in advance anyway!

Is This A Good Question/Topic? 0
  • +

Replies To: [Swift: Functions and Optionals] Need some simple Tuples Help

#2 WildPants   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-March 15

Re: [Swift: Functions and Optionals] Need some simple Tuples Help

Posted 19 March 2015 - 02:39 PM

Figured it out. Turned out that the return value just needed to be flipped.

From:

return (language, greeting)




To:

return (greeting, language)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1