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

Ricardo Ramirez
Ricardo Ramirez
917 Points

Unresolved Identifier erro

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

Unresolved identifier even tho xcode clearly prompts me to input a String. Please help =]

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

2 Answers

Andrew Shook
Andrew Shook
31,709 Points

The problem here is that you did not wrap the name Jerry in quotation marks. Since it's not wrapped in quotation marks, swift thinks you are trying to reference a variable or constant named Jerry. Hence, the error "use of unresolved identifier 'Jerry'' ". Just remember that string must be wrapped in single or double quotes you'll be fine.

Ricardo Ramirez
Ricardo Ramirez
917 Points

Holy Moly. you were completely right. I tried adding quotes but included person before I asked this hahaha silly me. Thank you so much!!! Moving forward now thanks again bro!