Welcome in escorting lecture, I'm going to show you a few examples in the coding, Ed. If you're ready,
let's get started.
Let's say there is a bookstore named Hipsters Love, they publish only four books every year in this
lesson.
Our job is to store and display the books, so let's declare a string array with four elements to store
the books.
Now let's first print its type using print F.
So the Aries type is for string theory, right?
All right, now let me print their.
It prints an empty array only with squired braces.
Actually, it is better to print it using print like this.
I've used the key word here because the area contains citrine values.
OK, all right, let's run it.
Much better, right?
There is also another way to an error.
Let's change this TURP here to this dashkova.
So this Dash Vivir prints the erase type and its elements together.
OK, good.
All right, let's say the bookstore publishes only one book for the winter season and three more books
for the summer season.
OK.
So as an example, let's change this length here with a constant expression, let's type it's flanked
like this Bamburgh for the Winter and plus three books for the summer.
As you can see, the output is the same as before.
Right.
This is because Gore has calculated the length of the error from this expression.
As for.
OK, now let's put this one and three into named constants like this winter.
Summer.
And let's add them together in a new constant.
OK, now I can use this yearly constant instead of these magical values here like this good.
As you can see, the output is the same as before.
Right.
OK, now let's invent some book titles and put them into these books.
OK.
But let me first remove these print calls here.
Now I'm going to type books that index zero, then I'm going to type Kavkaz Revanche here.
All right.
This is going to assign Kavkaz Revanche to the first element of these books.
And then let's assign State Golden to the second element.
And lastly, let's assign everything ship to the third element.
OK, all right, that's right.
Looks good, by the way, Hipsters Bookstore has decided to publish the second edition of the first
book here, Kafka's Revenge.
So first, I'm going to get the last element like this.
Then I'm going to get the first element.
I'm going to combine it with the second edition string, literal as you can see, right elements are
just like variables.
For example, books zero element here is just a string variable and its name is books index zero.
So it only has a name through the books array value by using an index expression.
OK.
OK, let me run it now.
Here it is, Kavkaz Reinsch, second edition, cool.
Now, I'm going to try to set an element beyond the element of this array like this.
Is this going to work, please pass the video now and think about it.
OK.
It doesn't work, of course, because this area is land is far and the indexes start from zero, so
there isn't a fifth element actually there is a movie about it anyway.
The interesting thing here is that Go Compiler has called this indexing problem without running the
program.
It's because I've used this constant remember this for is an integer literal, which is a constant.
Let's see what would happen if I use a variable instead, like this one.
Now let's replace this constant Litoral with this variable change.
See an error?
Well, I can't the go compiler couldn't catch the error.
It's because the index expression uses a variable.
Now, go compiler can't know the value of this variable until the runtime, so let's run it.
As expected, the program crashes when I run it.
So always keep this in mind.
But let me take this back.
OK.
All right, that's all for now in the next lecture.
I'm going to continue this example.
Let's take a quick break here now.
Thank you for watching so far.
Seeing the next lecture.
Our.