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

iOS Swift Functions and Optionals Parameters and Tuples Named Parameters

AR Ehsan
AR Ehsan
7,912 Points

Challenge Task 2 of 2 Call the greeting function and pass it the String "Jerry"

I am stuck!

named_parameters.swift
func greeting(#person: String) {
    println("Hello \(person)")
}
greeting(String: "Jerry")

1 Answer

Devin Scheu
Devin Scheu
66,191 Points

Hey, instead of saying String:, you want to say person: like this:

func greeting(#person: String) {
    println("Hello \(person)")
}

greeting(person: "Jerry")

If you think my answer was good, feel free to mark it as best answer below, if you need more help in the future from me, you can contact me at devinwscheu@gmail.com.

AR Ehsan
AR Ehsan
7,912 Points

Thanks! But somehow I figured it out!

AR Ehsan
AR Ehsan
7,912 Points

I will mark as best answer if you could help me with the decomposing tuples challenge! Here is my code! Challenge 3 of 3 func greeting(person: String) -> (greeting : String,language : String ){ let language = "English" let greeting = "Hello (person)"

      return (greeting ,language)
      println()
       }

        var result = greeting("Tom")
AR Ehsan
AR Ehsan
7,912 Points

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

  return (greeting ,language)
  println()
   }

    var result = greeting("Tom")
Devin Scheu
Devin Scheu
66,191 Points

Hey, this is the code I got for this challenge:

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)