1 00:00:00,780 --> 00:00:06,300 So in this lesson we're going to talk about enumerations or what we call EON's you know is that essentially 2 00:00:06,300 --> 00:00:10,470 a way of time close sooner or related values with each other. 3 00:00:10,560 --> 00:00:17,310 So it becomes what we call a typesafe what it means is it means you have values such as south east north 4 00:00:17,310 --> 00:00:23,760 and west and you put all of them inside one value called let's say direction and then we can get direction 5 00:00:23,770 --> 00:00:26,230 dot south and direction that North. 6 00:00:26,370 --> 00:00:33,390 And the reason it is safe is simply because we have to use the dot operation because of that is constrained. 7 00:00:33,480 --> 00:00:36,970 We cannot accidentally right a wrong value in there. 8 00:00:37,020 --> 00:00:41,860 So we don't mind this go ahead and get started in ex-coach and see how you're going to do this. 9 00:00:42,090 --> 00:00:52,360 When I go to explore I start a new project let's call it informs us with might you know I'm safe I'm 10 00:00:52,360 --> 00:00:57,190 going to go ahead and say get rid of all of that as usual. 11 00:00:57,220 --> 00:01:03,130 So if you remember earlier on in some of our previous lessons we're talking about a an application that 12 00:01:03,130 --> 00:01:08,920 essentially is a real estate listing application and we said some of the listings are for sale. 13 00:01:09,070 --> 00:01:10,830 Some of them are for rent. 14 00:01:10,840 --> 00:01:14,560 So here is a vivid example of how to use enormous here. 15 00:01:14,620 --> 00:01:24,220 I'm going to say you know let's call it the property type and it has two cases case sale and case are 16 00:01:24,380 --> 00:01:25,290 right. 17 00:01:25,330 --> 00:01:27,070 So I have two types. 18 00:01:27,070 --> 00:01:28,170 One of them is for sale. 19 00:01:28,180 --> 00:01:29,260 One of them is for rent. 20 00:01:29,260 --> 00:01:31,180 Now let's see how we're going to use that. 21 00:01:31,320 --> 00:01:37,830 And why go ahead and say class and my classes property doesn't have a superclass. 22 00:01:37,910 --> 00:01:42,890 And yet I have a variable let's say address which is a string. 23 00:01:43,210 --> 00:01:48,770 And I have a variable type Ritchies proper type. 24 00:01:48,970 --> 00:01:56,590 And of course if I try to initialize this I have to say in its e-mail address which is a string as all 25 00:01:56,630 --> 00:02:08,800 dates and type which is proc type and of course self that address becomes empowered dress and self that 26 00:02:08,920 --> 00:02:18,000 type certainly becomes proper type or type site type. 27 00:02:18,060 --> 00:02:19,080 So simple as that. 28 00:02:19,080 --> 00:02:25,950 So every time we are making a property our right off the bat based on a kind of strange enough we can 29 00:02:25,950 --> 00:02:29,180 choose which one of these two conditions is that. 30 00:02:29,310 --> 00:02:41,070 So here again go ahead and say where this property is going to be a property that property is going 31 00:02:41,070 --> 00:02:42,260 to be an actress. 32 00:02:42,300 --> 00:02:51,350 Let's say take the street and then the input type is going to be propped type Perabo type dot Brant 33 00:02:51,360 --> 00:02:51,900 for instance. 34 00:02:51,900 --> 00:02:54,330 So I know this one is for rent. 35 00:02:54,690 --> 00:03:01,770 And now if you want to use this I could go ahead and say for instance if this was a member of an array 36 00:03:01,770 --> 00:03:05,420 and you were running a search now you can do all of those things yourself. 37 00:03:05,490 --> 00:03:22,060 I could say if this property dot product type is Propp type dot say it for instance then let's say display 38 00:03:22,060 --> 00:03:25,680 this or whatever that you think you want to be doing with it. 39 00:03:25,810 --> 00:03:31,130 So that's essentially the core concept of enumeration or enough times. 40 00:03:31,240 --> 00:03:36,180 So before I finished this lesson there is one more kind of Islam that I want to show you one that's 41 00:03:36,190 --> 00:03:38,670 enumeration Veit case. 42 00:03:38,680 --> 00:03:40,500 I tried to state. 43 00:03:40,590 --> 00:03:42,490 So here's how we do those. 44 00:03:42,490 --> 00:03:49,000 I'm going to go ahead and say you know I mean all our cities and it is. 45 00:03:49,000 --> 00:03:51,170 CHACE I treatable. 46 00:03:51,460 --> 00:03:57,800 And then the cases are Vancouver Sun from New York. 47 00:03:58,090 --> 00:04:09,430 And then I'm going to go ahead and say for let's call it city in cities all cases of Prince city for 48 00:04:09,430 --> 00:04:10,460 me. 49 00:04:10,460 --> 00:04:11,410 And that's about that. 50 00:04:11,410 --> 00:04:19,330 I can iterate through the objects in my cities through the chases in my enumeration. 51 00:04:19,330 --> 00:04:27,280 So as you mention very useful info and values are related to each other and you want them to be typesafe. 52 00:04:27,430 --> 00:04:34,960 So you know specifically which one you're choosing you're choosing property type data sale and you can 53 00:04:34,960 --> 00:04:40,900 obviously use those for a variety of purposes would end up seeing this happening more and more as we 54 00:04:40,900 --> 00:04:42,800 go through real applications. 55 00:04:42,850 --> 00:04:46,130 So our eyes should see you guys in the next lesson I guess.