Loading
Current section: 8. Enums 4 exercises
lesson

Intro to Enums

Loading lesson

Transcript

00:00 Alright. Welcome to the enums exercise. Not a huge fan of enums myself, but you're going to see them and so we're gonna teach them to you. Enums are a special syntax for creating a, a type that has properties that map to, specific values. So, typically, you have a, type that can point to one of several enums.

00:22 So we have a status pending, active, and completed, and an order status can be one of those things. You can also do numeric enums and they are auto incremented automatically. So you just leave off this assignment here and just do up, down, left, right, whatever. And they will automatically be, create a number for you. Because the only important part of the enum is that it actually has a unique value amongst the other enums.

00:48 So, yeah. That's pretty much the the whole thing. We're gonna focus on the string version, but yeah. You can do it this way too. I don't like enums because I don't think they generate additional code that is run at run time and, they're not really all that beneficial above just using a union and they add additional limitations on you that we'll talk about in the exercise.

01:10 But like I said, you're gonna have to, you're probably going to see them in the wild, and so I want to, teach you how they work. So without any further ado, let's jump right into it.