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 Enumerations and Optionals in Swift Introduction to Optionals Downsides to Using If Let

Joseph Pizzo
Joseph Pizzo
Courses Plus Student 1,684 Points

Downsides to using Let- !Use of unresolved identifier 'address'

I have been follow along with all of the videos and keeping up pretty well, most of my issues have been with syntax (leaving out a curley brace or comma when needed) I canusually fix those pretty quickly.

This issue is with the downsides of using let. I keep getting the same error in xcode 9.2 and xcode 8.2 here is my code I dont know why i am getting this error and it is really frustrating! any help is appreciated

struct Friend {
    let name: String
    let age: String
    let address: String?

func new(friendDictionary: [String : String]) -> Friend? {
    if let name = friendDictionary["name"], let age = friendDictionary["age"] {
        return Friend(name: name, age: age, address: address)
    } else {
        return nil

1 Answer

Jari Koopman
.a{fill-rule:evenodd;}techdegree seal-36
Jari Koopman
Python Web Development Techdegree Graduate 29,349 Points

Hi Joseph,

What's going wrong here, is that you're using a value that's not declared anywhere. This happens in this line:

return Friend(name: name, age: age, address: address)

You give an address value to the initialiser, but you haven't defined it anywhere. This results in the compiler telling you you're using an unresolved identifier. What you can do to fix this, is either: A. Define an address and pass it to the initialiser B. Since address is an optional property on the struct, you can also pass nil to the initialiser to not give an address to the person

Hope this helped,

Regards, Jari