[MUSIC] All right, so now we can do things like call that property, or call the methods on the enum type. So here I have MilkyWayPlanet.Earth.order. And notice how properties and functions of enum types are called using dot syntax just as we expect for any other type like we've been working with. So we know that Earth is the third planet away, and we kept this zero index. So, zero, one, two, is the third planet and indeed, over here on the right hand side, we see its order is 2, so that's good, that's what we expect. Now we can say, let firstPlanet, of type MilkyWayPlanet = .Mercury. Notice how we were able to just say .Mercury instead of having to say MilkyWayPlanet.Mercury, because we explicitly typed this constant called firstPlanet, as of type MilkyWayPlanet. Also note how, even though in this playground we have our MilkyWayPlanet enum, and we also have our Planet enum. If we come back down here, notice how we have a case called Mercury on both of those enums. Even though we have two Mercurys in this playground, or two Mercurys in this scope because we defined the type as being of type MilkyWayPlanet, it will know which enum type .Mercury this instance is associated with. Let's just take a quick look, if I cut this away and don't explicitly type firstPlanet then I'm going to get an error. And the compiler would complain, type of expression is ambiguous without more context. Because it needs to know is this the planet .Mercury or MilkyWayPlanet.Mercury? So if I replace the explicit typing then the compiler knows which one to use. Okay, and same thing here with just saying let thirdPlanet = .Earth, we get the same complaint. Okay, so let me comment that back out. Let's take a look now at how we can call those methods that we defined on the MilkyWayPlanet enum. So in our earlier examples, we had to do a lot of work and long functions to list out the names of the moons. because our planets existed as dictionaries. We had to go first see if there was a moon's array inside of the planet dictionary. Then we'd have to go iterate over all of the moons and turn those into proper English sentences, etc. And that was a lot of code typing that we had to do. Here, we've listed out the moons in a much simpler fashion. Maybe not as nice English sentences, but with a lot less typing, we can show the moon count and show the moon names. So here I just a do a simple for loop and I've created an array of the MilkyWayPlanets called theMilkyWay. And here I've populated an array with a bunch of different Milky Way planets. And I say for planet in theMilkyWay, even though I know that our planets are just one solar system in the Milky Way, but let's just go ahead with this example because I had to call it something different. So for planet in theMilkyWay planet.showMoonCount( ) and planet.showMoonNames( ). Now over here on the right-hand side it's not actually going to do that because there's sort of not enough space for it to do it in line with each line of code. So, we have to go look at our console for that. So, I'm going to click this middle button here up in the right hand corner where you see three buttons together, and it says hide or show the debug area. So, that will bring my console up at the bottom and I'll drag this up so we have a little bit more space to see what's going on. And here we have for planet in theMilkyWay, planet.showMoonCount. And keep in mind, showMoonCount just shows us, prints out the number of moons, and showMoonNames which prints out a list of the moon names. So here we see. We're going to start off with Mercury and, of course, we know Mercury has no moons. So we get showMoonCount, 0, showMoonNames, no moons. Same thing for Venus as the next one in the order, 0 moons, no moons. Now we get to Earth, one moon and it's called Luna, and we go ahead and we go down all the list of planets in our array called theMilkyWay and we can see the number of moons and the list printed out. So our code's working as expected. All right, I wanted to show you again one more time, we typically might not do this because it's not very expressive. Here, our code is very expressive, we have an array, and we can clearly see the planets inside of our array, Mercury, Venus, Earth, etc. But these planets also have an integral value associated with them, so I could have said, let orderedSolarSystem equal zero, one, two, three, four, five, six, seven. And this is maybe expressive in a different way, it's not as easy to see the name of the planet that we're talking about in code, but we can see which planet is it in terms of order of distance from the sun. So now I can create planets out of these Ints using the init with raw value initializer we saw earlier. So now I can say for planet in orderedSolarSystem, so that's the name of this array. MilkyWayPlanet init with rawValue, the planet which is again, going to be an Int because this is the value that it's getting out of the array as it iterates over the array. Now I've created a planet and if I was successful in creating a planet with a valid rawValue, then I will have a valid instance of the planet. Whatever the case may be. Now I can ask it, .showMoonCount, and that will work out just fine down here in the console. [MUSIC]