WEBVTT 00:01.110 --> 00:07.860 Welcome in escorting lecture, I'm going to show you a few examples in the coding, Ed. If you're ready, 00:07.890 --> 00:08.560 let's get started. 00:09.480 --> 00:16.460 Let's say there is a bookstore named Hipsters Love, they publish only four books every year in this 00:16.470 --> 00:16.890 lesson. 00:16.950 --> 00:24.810 Our job is to store and display the books, so let's declare a string array with four elements to store 00:24.810 --> 00:25.360 the books. 00:25.800 --> 00:28.610 Now let's first print its type using print F. 00:30.760 --> 00:33.880 So the Aries type is for string theory, right? 00:34.030 --> 00:36.400 All right, now let me print their. 00:38.960 --> 00:42.190 It prints an empty array only with squired braces. 00:42.970 --> 00:46.760 Actually, it is better to print it using print like this. 00:48.550 --> 00:53.310 I've used the key word here because the area contains citrine values. 00:53.350 --> 00:55.300 OK, all right, let's run it. 00:56.260 --> 00:57.100 Much better, right? 00:57.760 --> 00:59.970 There is also another way to an error. 01:00.370 --> 01:03.860 Let's change this TURP here to this dashkova. 01:04.660 --> 01:09.340 So this Dash Vivir prints the erase type and its elements together. 01:09.400 --> 01:10.810 OK, good. 01:11.290 --> 01:17.620 All right, let's say the bookstore publishes only one book for the winter season and three more books 01:17.620 --> 01:18.730 for the summer season. 01:18.790 --> 01:19.180 OK. 01:20.410 --> 01:27.010 So as an example, let's change this length here with a constant expression, let's type it's flanked 01:27.010 --> 01:31.450 like this Bamburgh for the Winter and plus three books for the summer. 01:32.180 --> 01:35.410 As you can see, the output is the same as before. 01:35.480 --> 01:35.890 Right. 01:36.200 --> 01:40.900 This is because Gore has calculated the length of the error from this expression. 01:40.900 --> 01:41.640 As for. 01:41.780 --> 01:48.520 OK, now let's put this one and three into named constants like this winter. 01:49.860 --> 01:50.400 Summer. 01:51.260 --> 01:54.050 And let's add them together in a new constant. 01:55.110 --> 02:01.950 OK, now I can use this yearly constant instead of these magical values here like this good. 02:02.810 --> 02:05.800 As you can see, the output is the same as before. 02:05.890 --> 02:06.130 Right. 02:07.180 --> 02:12.640 OK, now let's invent some book titles and put them into these books. 02:13.230 --> 02:13.600 OK. 02:14.540 --> 02:17.240 But let me first remove these print calls here. 02:19.720 --> 02:26.830 Now I'm going to type books that index zero, then I'm going to type Kavkaz Revanche here. 02:27.510 --> 02:28.020 All right. 02:28.060 --> 02:32.560 This is going to assign Kavkaz Revanche to the first element of these books. 02:32.920 --> 02:36.280 And then let's assign State Golden to the second element. 02:37.180 --> 02:40.900 And lastly, let's assign everything ship to the third element. 02:42.360 --> 02:44.880 OK, all right, that's right. 02:45.800 --> 02:51.920 Looks good, by the way, Hipsters Bookstore has decided to publish the second edition of the first 02:51.920 --> 02:53.430 book here, Kafka's Revenge. 02:53.840 --> 02:56.690 So first, I'm going to get the last element like this. 02:57.770 --> 02:59.300 Then I'm going to get the first element. 03:00.290 --> 03:06.340 I'm going to combine it with the second edition string, literal as you can see, right elements are 03:06.340 --> 03:07.600 just like variables. 03:08.200 --> 03:15.460 For example, books zero element here is just a string variable and its name is books index zero. 03:15.730 --> 03:20.740 So it only has a name through the books array value by using an index expression. 03:20.920 --> 03:21.310 OK. 03:22.220 --> 03:23.240 OK, let me run it now. 03:23.720 --> 03:26.670 Here it is, Kavkaz Reinsch, second edition, cool. 03:26.990 --> 03:32.120 Now, I'm going to try to set an element beyond the element of this array like this. 03:33.140 --> 03:36.880 Is this going to work, please pass the video now and think about it. 03:36.970 --> 03:37.280 OK. 03:46.320 --> 03:53.580 It doesn't work, of course, because this area is land is far and the indexes start from zero, so 03:53.580 --> 03:58.400 there isn't a fifth element actually there is a movie about it anyway. 03:59.460 --> 04:05.100 The interesting thing here is that Go Compiler has called this indexing problem without running the 04:05.100 --> 04:05.560 program. 04:06.360 --> 04:13.170 It's because I've used this constant remember this for is an integer literal, which is a constant. 04:14.270 --> 04:18.470 Let's see what would happen if I use a variable instead, like this one. 04:18.710 --> 04:22.660 Now let's replace this constant Litoral with this variable change. 04:22.670 --> 04:23.280 See an error? 04:23.780 --> 04:27.310 Well, I can't the go compiler couldn't catch the error. 04:27.560 --> 04:30.740 It's because the index expression uses a variable. 04:30.770 --> 04:37.550 Now, go compiler can't know the value of this variable until the runtime, so let's run it. 04:37.700 --> 04:40.420 As expected, the program crashes when I run it. 04:40.970 --> 04:42.380 So always keep this in mind. 04:43.070 --> 04:44.690 But let me take this back. 04:45.180 --> 04:45.590 OK. 04:46.710 --> 04:49.230 All right, that's all for now in the next lecture. 04:49.440 --> 04:51.240 I'm going to continue this example. 04:51.580 --> 04:53.160 Let's take a quick break here now. 04:53.610 --> 04:54.780 Thank you for watching so far. 04:54.870 --> 04:55.950 Seeing the next lecture. 04:56.100 --> 04:56.480 Our.