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.

Will Van de Walle
2,352 PointsCode Challenge: What?
I am utterly confused about the code challenge. I've taken a long break from this course and I'm trying to get back into it, and I just don't understand how to do this with enums. There doesn't seem to be any connection between the constants and the enum cases, and I'm just confused. Help?
2 Answers

Gabriel Mititelu
5,881 PointsHello, Will.
If I remember correctly, the challenge asks you to create a computed property that returns a string.
Try creating the computed property within the enum, and switching on it(self). For each case, it should return the appropriate string. The string have been assigned to the constants. Also, consider watching the lesson again to brush up on computed properties.
If I've been vague, do ask away for clarification.

Gabriel Mititelu
5,881 PointsHi, Christian.
- To start you off, you need a computed property named style that returns a string :
var style: String {}
Secondly, you need to return a string for each enum case. Giving that this is an enum, I think a switch statement would fit perfectly.
The computed property is within the enum, and the switch will be within the enum too. Thus, you need to use the keyword self to switch on.
I believe there are 3 constants, above the enum, containing the appropriate string for each enum case. Use those instead of passing in the string directly.
Here's a template:
let first = "string"
let second = "string"
let third = "string"
enum numbers {
case 1
case 2
case 3
var style: String {
switch self {
case .1: return first
case .2: return second
case .3: return third
}
}
}
christian elam
6,443 Pointschristian elam
6,443 PointsI am sorry but I am also having the same problem could you clarify or share what you did? Please. Much appreciated