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 trialNev Wood
Courses Plus Student 5,793 PointsWhat does "using a raw value with Compass' initializer method" mean in this challenge?
The below code works fine in swift playground and returns the enum rawValue for the enum case south:-
enum Compass: Int { case north = 10 case south = 20 case east = 30 case west = 40 }
let direction = Compass.south.rawValue
Is there a bug in the challenge or is it the use of the use of the Compass' initializer method that causes the challenge to fail? Not really sure I understand exactly what an enums initializer method actually means in plain English.
enum Compass: Int {
case north = 10
case south = 20
case east = 30
case west = 40
}
let direction = Compass.south.rawValue
2 Answers
Magnus Hållberg
17,232 PointsThe contest say you should use the rawValue initializer, so it should look something like this. let direction = Compass(rawValue: 20)
Nev Wood
Courses Plus Student 5,793 Pointsseemed to work though the challenge mentions assigning Compass.south. Oh well passed the challenge so onwards and upwards. thanks for the help.