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


Peter Fuhrey
Peter Fuhrey
2,146 Points

Help with unresolved identifier issue in struct method.

Can anyone help me with this code? Or maybe a better suggestion to accomplish this task? It's saying use of unresolved identifier but I thought North was declared in my constant? I'm trying to get it to print out what state you're heading towards depending on your direction. (North = New York, East = Carolinas, South = Florida, West = California) import Foundation

struct CompassPoints {

   let compassDirections = ["North", "East", "South", "West"]

    func stateBound() -> String? {
        for direction in compassDirections {
            switch direction {
            case North:
                return "You're heading towards New York"


1 Answer

Try this:

enum CompassPoints {
    case North, East, South, West

    func stateBound() -> String {
        switch self {
        case .North:    return "New York"
        case .East:     return "Carolinas"
        case .South:    return "Florida"
        case .West:     return "California"


let North = CompassPoints.North
let Northdir = North.stateBound()
println("You're heading towards  \(Northdir).")