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

Can't tell what this question is asking

these questions seem to be getting vaguer and vaguer... in this challenge, I can't tell what they want from me. The following haven't worked.

enum Compass: Int { case North = 1 case South case East case West }

let Direction = Compass(rawValue: 2)

\

enum Compass: Int { case North = 1 case South case East case West }

let Direction = Compass.South.rawValue

\

enum Compass: Int { case North = 1 case South case East case West }

let someValue = 2 let Direction = Compass(rawValue: someValue)

1 Answer

Michael Reining
Michael Reining
10,101 Points

Hi Andrew,

You are close. Remember that constants and variables should be lowercase.

let direction // use lowercase d

Also, when declaring your enum, you can keep the code shorter and more readable by following the convention below.

enum Compass: Int {
    case North = 1, South, East, West // comma separate each case
}

let direction = Compass(rawValue: 2)

I hope that helps,

Mike

PS: Thanks to the awesome resources on Team Treehouse, I just launched my first app. :-)

Code! Learn how to program with Swift