WEBVTT 00:00.800 --> 00:06.070 Welcome again in his lecture, I'm going to show you why do you need to use a hota and what is that? 00:06.500 --> 00:07.160 Let's start. 00:09.070 --> 00:12.950 They say that you want to declare constants that represent the days of the week. 00:13.390 --> 00:17.170 This way you will prevent the magic numbers in your code, right? 00:17.680 --> 00:20.230 So each day will be represented with a unique number. 00:20.740 --> 00:25.840 To do that, you need to initialize the constants with increasing numbers for each day or they will 00:25.840 --> 00:26.410 clash. 00:27.720 --> 00:31.440 First, let's to declare a few constants for the week, this. 00:32.500 --> 00:35.200 The first one is Monday, and its value is zero. 00:35.560 --> 00:38.340 Second one is Tuesday and its value is one. 00:39.190 --> 00:43.120 As you can see, I am increasing the numbers one by one for each constant. 00:43.600 --> 00:45.850 And it goes like this until Sunday. 00:51.680 --> 00:52.910 OK, now let's bring the. 00:59.990 --> 01:00.880 OK, let's try it. 01:04.220 --> 01:11.450 This prints the numbers from zero to six, as expected, because I know about the features I've got, 01:11.450 --> 01:15.300 typing it like this looks unnecessary to me in a second. 01:15.320 --> 01:16.870 You will also think the same thing. 01:17.980 --> 01:20.110 It's because God can do this for you. 01:20.260 --> 01:21.000 Let's check it out. 01:22.880 --> 01:25.070 As you can see, I removed the constant value. 01:25.700 --> 01:30.350 Now you're going to learn how to use the IETA, the number generator for constants. 01:30.680 --> 01:33.680 Let's initialize the first constant with Ayata now. 01:35.460 --> 01:36.290 OK, let's run it. 01:38.680 --> 01:42.410 As you can see, it prints the same output just like the previous example. 01:43.250 --> 01:44.690 So how does this work? 01:44.990 --> 01:45.800 Is it magic? 01:46.620 --> 01:54.000 Yes, it's magic, it uses the following features of go first constants, repeat the previous constants, 01:54.000 --> 01:58.650 type an expression, second ayata the number generator for constants. 01:59.280 --> 02:02.310 As I said, IETA is a number generator for constants. 02:02.340 --> 02:05.550 Think of it like an ever increasing automatic counter. 02:06.610 --> 02:13.060 For each new constant here, I will generate a new number automatically because each constant will repeat 02:13.060 --> 02:17.350 iota as its initial value, as if they're being initialized with IETA. 02:18.220 --> 02:24.940 So I will keep increasing itself on this while it becomes zero, because it starts at zero. 02:25.830 --> 02:33.930 And Tuesday becomes one because Gore increases the Ayata for each constant and Wednesday becomes two, 02:34.350 --> 02:45.060 Ayata keeps increasing, Thursday becomes three, Friday becomes for, Saturday becomes five, and lastly, 02:45.060 --> 02:46.800 Sunday becomes six. 02:47.550 --> 02:52.120 And after the multiple constant declaration and Gore sets Diatta. 02:52.920 --> 02:55.640 So if you use it, it's another constant declaration. 02:55.650 --> 02:57.240 It will start from zero again. 02:58.240 --> 03:02.650 As you can see here, IETA keeps increasing automatically for each constant. 03:03.430 --> 03:06.130 So behind the scenes constant repeat ieta. 03:07.050 --> 03:13.260 This happens because a constant repeat the type and the expression of the previous constant. 03:14.540 --> 03:16.100 Let's take a look at another example. 03:18.620 --> 03:25.370 It's you know, you can use expressions, initializing consonants, since IETA is actually a value, 03:25.430 --> 03:28.380 so you can use it in a constant expression as well. 03:28.850 --> 03:29.650 Let's check it out. 03:30.950 --> 03:34.940 As an example, let's add one to IETA initializing the Monday. 03:35.820 --> 03:41.790 Now, this expression just adds one to iota and generates a new value before assigning it to the Monday 03:41.790 --> 03:42.340 constant. 03:43.170 --> 03:44.490 So what do you think about this? 03:44.520 --> 03:48.810 I mean, what values these concerns we will get when I run this post video? 03:48.840 --> 03:52.140 Now, think about this for a minute or so, then continue. 03:54.290 --> 03:56.150 OK, let's turn it now and find out. 03:57.410 --> 03:59.860 As you can see this time, the result is different. 04:00.020 --> 04:05.190 Instead of starting from zero, Monday has started from one and others have followed it. 04:05.540 --> 04:07.090 Now let's see how it works. 04:08.380 --> 04:12.770 At first, IETA starts at zero, but the expression is Ayata plus one. 04:13.300 --> 04:20.470 So Monday becomes vom instead of zero and Tuesday repeats the previous expression and it becomes too 04:20.500 --> 04:28.870 two because Ayata is vonne, but the expression is ieta plus one iota becomes too and Wednesday becomes 04:28.870 --> 04:29.320 three. 04:29.800 --> 04:38.290 After that IETA becomes three and Thursday becomes for next Ayata becomes four and Friday becomes five. 04:39.310 --> 04:48.100 An iota becomes five and Saturday becomes six, unless the ayata becomes six and someday becomes seven. 04:49.310 --> 04:55.730 As you can see, each constant repeats the mon's expression, so each constant repeats ieta plus one 04:55.730 --> 04:59.540 expression using an expression that depends on your imagination. 04:59.820 --> 05:02.580 It can be very powerful for ideas. 05:02.600 --> 05:05.050 Please check out my blog post about IETA. 05:05.570 --> 05:07.520 It contains a lot of tips and tricks. 05:07.670 --> 05:09.890 I attached the link in resources for it. 05:10.800 --> 05:14.080 Now let's take a look at how to use the blank identifier with Iota. 05:14.870 --> 05:20.690 Remember, the blank identifier is like a black hole which eats values without any point of return. 05:21.140 --> 05:21.910 Let's take it out. 05:23.170 --> 05:27.880 They say that you want to declare constants for representing a few common time zones. 05:28.660 --> 05:30.550 Let me show you the time zones table. 05:30.550 --> 05:34.260 First is the here means Eastern Standard Time. 05:34.870 --> 05:38.590 It is five hours behind of UTC, by the way. 05:38.590 --> 05:40.600 UTC means universal time. 05:41.080 --> 05:49.780 And Misty is Mountain Standard Time, and it is seven hours behind of you to see unless the city is 05:49.780 --> 05:54.070 California standard time and it's eight hours behind of UTC. 05:55.060 --> 05:58.420 So according to this table, how should I declare Constance? 06:00.900 --> 06:01.590 Let me show you. 06:03.020 --> 06:06.590 Let's first declare Constance using a multiple constant declaration. 06:08.170 --> 06:13.360 I'm going to declare three constants, which will represent the time zones according to the table, 06:13.900 --> 06:20.360 they should be minus five and they should be minus seven and they should be minus eight. 06:21.040 --> 06:24.340 So let's declare a constant for E as minus five. 06:25.790 --> 06:29.540 Domestically and other concerns for amnesty, it should be mine seven. 06:30.840 --> 06:34.140 And lastly, let's declare you should be minus eight. 06:34.590 --> 06:36.780 OK, great, now print those constants. 06:37.910 --> 06:38.750 OK, listen, it's. 06:40.250 --> 06:44.090 OK, now let's suppose that the actual time zone table is much more longer. 06:44.330 --> 06:46.300 If so, then it's better to use IETA. 06:47.000 --> 06:48.190 But how can I do that? 06:48.320 --> 06:49.460 This figured out next. 06:51.180 --> 06:56.220 No, I removed the initial values from the constants, that's because I want it replaced, I'm using 06:56.220 --> 06:56.690 Gouta. 06:57.450 --> 07:03.990 In the meantime, I calculate with a formula or actually I stole it from one of the examples I striated 07:03.990 --> 07:04.560 Ioanna. 07:05.990 --> 07:11.240 Now, four of the boxes next to the Constance, I'm going to display what my formula competes for each 07:11.240 --> 07:11.780 constant. 07:12.690 --> 07:15.900 So according to my formula, E will be minus five. 07:20.170 --> 07:21.700 Creates my formula works. 07:22.090 --> 07:23.730 Let's look at Misti constant now. 07:24.710 --> 07:27.500 According to the Time Zones table, it should be minus seven. 07:27.750 --> 07:28.430 Let's check it out. 07:29.280 --> 07:34.690 It looks like my formula has calculated it as minus six, but it should be minus seven. 07:35.000 --> 07:37.310 Bomber, some formula doesn't work. 07:38.020 --> 07:39.050 Let's continue for now. 07:39.740 --> 07:41.750 Let's look at the constant this time. 07:42.670 --> 07:48.090 Is incorrect as well, my formula returns minus seven is minus eight on the table. 07:49.090 --> 07:51.340 So my formula definitely doesn't work. 07:51.820 --> 07:52.680 OK, let's run it. 07:53.730 --> 07:59.850 Compare the output to the time zones table, you'll see that the program's output slips minus one hour. 08:01.050 --> 08:08.340 So to solve this problem right on this line between Estey and Misty, I need to increase Ayata without 08:08.340 --> 08:10.600 declaring another Konstanty, right. 08:11.430 --> 08:15.280 So if I do that, then the constants will match to the time zones table. 08:15.720 --> 08:16.550 Let's do that now. 08:18.060 --> 08:22.120 Now, I moved Misty and Constance Van Line down. 08:22.800 --> 08:27.900 Now I'm going to add a blanket and fire right between the east and the misty constants like this. 08:29.040 --> 08:30.660 This recalculate the value again. 08:31.470 --> 08:32.670 Let's start with S-T. 08:33.510 --> 08:40.530 I vote is zero now, so if I put iota into my formula, it becomes five plus zero, which is five and 08:40.530 --> 08:44.420 one multiplied by minus one is C becomes minus five. 08:44.430 --> 08:46.230 Now, cool is correct so far. 08:46.590 --> 08:48.090 Now, let's take a look at the next line. 08:48.600 --> 08:50.210 I will keep increasing here. 08:50.550 --> 08:56.520 So the formula looks like this five plus one multiplied by minus one is minus six. 08:57.250 --> 08:59.640 This value will be assigned to the black identifier. 09:00.360 --> 09:05.460 Remember, the blank identifier is like a black hole, but to send into it will disappear. 09:06.360 --> 09:08.160 OK, now let's take a look at Mauti. 09:09.390 --> 09:15.960 Five plus two multiplied by minus one is minus seven, good, according to the Times on Seybold is also 09:15.960 --> 09:16.420 correct. 09:17.220 --> 09:22.660 And lastly, take a look at the five plus three multiplied by minus one is minus eight. 09:23.580 --> 09:24.950 So this is also correct. 09:29.390 --> 09:34.430 As you can see, by using a blank identifier, I can adjust the values of the constants correctly. 09:35.490 --> 09:40.950 I use the blank identifier only for increasing Diatta, and I didn't use it ever after. 09:41.610 --> 09:48.150 So you can use a blank identifier an iota to adjust the values of your constants to perfect. 09:48.840 --> 09:49.200 All right. 09:49.210 --> 09:49.970 That's all for now. 09:49.980 --> 09:51.270 Thank you for your patience. 09:51.300 --> 09:52.380 See you in the next lecture.