Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?