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 Objective-C Basics Introduction to Operators and Conditionals Review Switches and Enums

Bernard Chan
Bernard Chan
36,471 Points

Why is yellow 4?

I don't see any number assigned to yellow, but the answer is 4, why?

1 Answer

Ritesh R
PLUS
Ritesh R
Courses Plus Student 17,865 Points

Bernard Chan As the color blue has been assigned the number '0' it automatically assigns the rest of the enum elements the numbers 1,2,3,4 respectively in order, as no values have been assigned to it explicitly. If you require un-ordered set of values then you can assign it yourself for example blue = 2, purple = 5, red = 1..and so on!!