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

Wei Luo
Wei Luo
1,372 Points

Task 2

It keeps telling me to call greeting but isn't greeting() means I've called the func??

named_parameters.swift
func greeting(#person: String) {

}
greeting(person:"Jerry")
Martin Wildfeuer
Martin Wildfeuer
Courses Plus Student 11,071 Points

Try to find out how your code differs from mine, I am veeeery confident it works ;) The Swift 2 track also starts from the very beginning, no worrie :)

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

I think you inadvertently deleted the body of greeting, which will print the name. This should pass:

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

greeting(person: "Jerry")

However, the # for creating an external parameter is obsolete with Swift 2. You are doing the Swift 1 course, I strongly recommend doing the Swift 2 course instead, as some of the information here is outdated and won't work with the latest iOS SDK.

Follow this link for the Swift 2 track.

Wei Luo
Wei Luo
1,372 Points

Thanks Martin!!

BTW, due to I am new to all the coding stuff, I'm wondering that will SWIF 2 course explain everything?