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

Still not working.

Error says: swift_lint.swift:11:9: error: missing argument for parameter 'person' in call greeting() ^

named_parameters.swift
func greeting(#person: String) {   // remove the '#'
    println("Hello \(person)")
}

greeting()

3 Answers

Richard Lu
Richard Lu
20,185 Points

Hi Joshua,

I noticed that you looked at my answer to your previous post which was "How would I Call the greeting function and pass it the String Jerry". If you wanted to call the greeting function and pass it the string "Jerry", then you'd have to pass it to the function when you call it, like this:

greeting("Jerry")  // passing in "Jerry"

If you wanted to call greeting without any parameters (which doesn't make sense), then you'd have to define a default value which you'll learn later on in the course.

Good luck! :)

This still does not work

Richard Lu
Richard Lu
20,185 Points

Hey Daniel,

Do you mind giving me the error you're getting. Is it the same one or different?

If the error is due to running this on playground, Apple has changed this as of Swift 2.0+. The alternative to this solution would be:

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

greeting(person: "Jerry")
  • Rich

It's says: Bummer! You need to call greeting() lol.