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!

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

Rea Rahhal
Rea Rahhal
Courses Plus Student 4,732 Points

your code could not be compiled... what's wrong here?

The constant declaration is right, what am I missing ?

enum Compass: Int {
    case North = 1
    case South = 2
    case East = 3
    case West = 4

//let direction = Compass(rawValue: 2)
//let direction = Compass.South.rawValue
 let direction = Compass(rawValue: 2) 

1 Answer

Dave Harker
Dave Harker
Courses Plus Student 15,510 Points

Hi Rea Rahhal,

Nothing really wrong with the code per se.
The task however requires all lower case enum members i.e south not South

Nice work by the way ... you nailed it!! (just change the capitisation on the enum members) :dizzy:

Dave Harker
Dave Harker
Courses Plus Student 15,510 Points

Rea Rahhal — You can mark the question solved by choosing a "Best Answer".
And happy coding! :dizzy: