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

Swift Enums and Structs question

On the final quiz there is the question below. Which one of the following is a valid enum declaration?

Two answers are similar and I don't get why A is the correct one over C. Does the enum have to be capital or something?

A.) enum Genre { case Drama, Romance, Satire, Tragedy, Comedy } C.) enum genre { case drama, romance, satire, tragedy, comedy }

1 Answer

Hi, yes they have to be capitalized, according to the apple reference: Each enumeration definition defines a brand new type. Like other types in Swift, their names (such as CompassPoint and Planet) should start with a capital letter. Give enumeration types singular rather than plural names, so that they read as self-evident:

    var directionToHead = CompassPoint.West

Hope that helps!