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.

iOS Swift Enums and Structs Enums What is an Enum?

Arjun Amin
Arjun Amin
2,228 Points

How does the computer know that the day is a string?

Can someone help me with this?

3 Answers

If you mean how computer know the day and date , that is because the computer have internal db and this db updated by operating system website , so after install the operating system , your computer will connect to the time database and will update your time by your country and region .

if you mean how the computer present the day as string , this is different things because the day is a string we can not today is 6 we will say today is Wednesday .

Sorry but what you mean by your question give example or explain your question .

Ilari Niitamo
Ilari Niitamo
6,458 Points

With enums you're not working with strings at all. For example, Day.Monday is only a enumeration value. What the function in the video is comparing is two enums - the only thing that is a string is the printout, which is irrelevant. In Objective-C at least you could refer to enums by an index number, as well. So Day.Monday would be the same as 0, so your switch statement could say case 0...4: println("It's a weekday!") and case 5...6: println("It's the weekend!"). I don't yet know if this is possible with Swift, too.

Did that answer your question?