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

Question About Enums

Hello,

I've had this question about enums for a long time which prevents me from continuing my learning journey.

I know that an Enum is similar to a struct or a class in that its a blueprint / construct we use to model finite data/data with fixed amount of values.

My Question is: What exactly are the values/what do enum members represent except their name.

enum Day {
    case sunday
    case monday
    case tuesday
    case wednesday
    case thursday
    case friday
    case saturday
}

For Example -> What does 'case sunday' represents.

Thanks everyone in advance.

1 Answer

Bruce Röttgers
Bruce Röttgers
18,211 Points

Well it represents their raw value, which can be either a String or an Int depending on how you declare it. In case of an Int sunday would be 0, etc