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

Zachary Goforth
Zachary Goforth
748 Points

What is the error "unresolved identifier" mean?

It says "Jerry" is my unresolved identifier...

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

2 Answers

Kevin Gary
Kevin Gary
3,788 Points

You're calling the function within the function, when in fact you need to use the argument passed through the function to do what you want within the function.

A function (in Swift) that takes a parameter and prints it would look like: func greeting(person: String) { println(person) } ... where person is the argument passed in of type String.

then you can call this function: greeting("Jerry")

and it should print: Jerry

... changing the println to: println("Hello, (person)") will change the print statement to Hello, Jerry ... or whatever string you pass through when calling the function.

Hope this helps!

Kevin Gary
Kevin Gary
3,788 Points

ps

when you call the function you may have to write greeting(person: "Jerry"), where person is the parameter descriptor