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 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