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

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!