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 trialryansingh7
5,082 PointsStuck on a challenging question from Enums with Raw Values code challenge
Let's get in some practice creating enums with raw values. Declare an enum named Compass with a raw value of type Int.
Give the enum 4 members: north, south, east and west and assign them default raw values.
Assign the enum value Compass.south to a constant named direction, by using a raw value with Compass' initializer method.
My code:
enum Compass: Int {
case north = 1
case south
case east
case west
}
let direction = Compass.south.rawValue
It didn't pass the code challenge, must be a bug?
1 Answer
Amazon Web
iOS Development Techdegree Student 4,092 Pointslet direction = Compass(rawValue: 2)
The challenge is to create a instance of Compass.south enum using rawValue, your code will get the raw value of the Compass.south which is 2.
ryansingh7
5,082 Pointsryansingh7
5,082 PointsThank you!