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 Enumerations and Optionals in Swift Objects and Optionals Enums with Raw Values

Please Help

I can not figure out how to solve this issue

enums.swift
enum Compass: Int {
     case North = 1
     case South = 2
     case East = 3
     case West = 4
}
let direction = Compass(rawValue: 2)

1 Answer

Hannah Gaskins
Hannah Gaskins
14,572 Points

Hey there Mehran,

It looks like the code complies when you use the lowercase for all of the case statements. I literally copy and pasted your code and then lowercased the case statements with a successful compile.

enum Compass: Int {
     case north = 1
     case south = 2
     case east = 3
     case west = 4
}
let direction = Compass(rawValue: 2)

The Treehouse compiler can be VERY picky.

Hope this helps!