Welcome back, hipsters love bookstore owner told me that they want to store and display the winter
and the summer books separately, so I need to think about how to do that.
Well, the solution is easy.
I can simply use different areas for different seasons.
Right.
Let me show you.
Now I'm going to declare a new era for the winter books like this.
I have a winter constant already, which tells me about the number of books that the bookstore is going
to publish in this winter season.
OK, so here I'm going to use it and I'm going to set its element type to strength.
Remember, winter Constance value is one, so this area's length will also be one.
Now I'm going to assign the books first element to this W books array's first element.
OK, W Books means winter books, as you guessed, by the way.
So first I'm going to get the first elements from the books, then I'm going to assign it.
The books are first elements like this.
Let me put into this a.
Let's see how it looks.
It looks pretty now, the winter era has a copy of the first element of the books era, right?
They might also store the summer books in a new way.
I have the summer constant as well.
So now I'm going to use it to declare the land of this era like this.
OK.
Now, let's copy this summer books into this new era, the books erase the last three element stores,
the summer books.
So I'm going to copy the second book to bookstores, first element.
And let's also copy the third book to e-books.
The second element, OK?
And the last one.
All right, let me bring to Desa.
Now, the summer book are contains the last three elements of the book, Sarah, right.
Actually, there is a simpler way I can use a loop here, so let me comment on these assignments first,
then I'm going to create a follow.
This land function returns three because the length of the spokes area is three.
OK, all right.
Now I'm going to get an element of the book right at this index.
OK, and now I'm going to copy a book from the book's array at this index plus one.
Remember, the summer books are the last three books in the books.
Right.
That's why I have typed plus one here.
So it starts copying from the second element of the book.
OK.
OK, let's see what it does.
As you can see, the loop has copied the last three elements of the books array into the books Erin.
All right, cool.
Actually, there is a much simpler way I can use a full range loop.
Let's do that.
First of all, let me delete the rest of this line starting from here.
And instead I'm going to use a range clause here.
It's simpler.
All right.
That's it.
Let's take it out now.
As you can see, it brings the same output, right?
Although the results are the same, the underlying mechanics are very different than your range over
an area like this, it gets copied.
Let me show you.
Let me duplicate disarranged loop here now, instead of getting the indexers, I'm going to change this
and I'm only going to get the values from the books I write like this.
Let me also comment about this assignment and this printf calls first.
Let me first show you we variable here contains the elements of the book Boxer.
All right, that's right.
As you can see, it brings the elements of the book sorry, so far so good.
Now I'm going to delete this printer and I'm going to change the value by adding that new value LACHSA.
I'm also going to uncommented this printers so you can see what the arrays contain.
OK, all right, let's run.
It's.
As you can see, summer books are didn't change.
This is because this is a copy of the original element of the S books era.
So if you want to update the original error element, you can do so by directly accessing the element,
using an index expression as in the above loop.
OK, by the way, this is one of the gotchas that many beginner gophers fall into in the upcoming sections.
I'll talk about the underlying mechanics of this mulberries.
All right.
After this brief side note, let me take all this back.
Hipsters love bookstores owners also told me that they want to display the published books.
To do that, we need to keep track of the published books, right?
For example, I can create a Boolarra like this one to track them.
Here I used Lambrix as a length of this, published every.
Here is a question if the length of an era belongs to compile time, then how could I use the land function
here?
Please post the video and try to answer.
OK, it works because when you pass a constant to the land function, the land function also returns
are constant.
So when you compile your code, go will seem to replace this land books with four.
So in the end, this just creates a Boolarra with four elements.
All right.
OK, they're published their first book, so let's set the first element to true like this.
Remember, published Erra only contains Boulle elements, its element type is Boulle, right, so that's
why I can set it to a bool value here.
They also published the last book.
Let's set it to true as well.
First, I'm going to type Landmark's.
Then I'm going to type minus one, so this will get the last element, OK, and lastly, I'm going to
set these last element to true good.
Now let's print only the published books.
First, I'm going to create a header like this.
Then I'm going to arrange over the published array like this.
All right, I only want to print the published books, so I'm going to type and if Glozier.
Remember this OK, variable, it cools to the next bool element inside the published area, right?
And now I'm going to print a published book like this, let me type elsewhere here for the book's title,
then I'm going to get the book from the book using the index variable.
I can do this because the length of the published and the books are a lot of the same.
All right, let's run this code now.
Put it on the prints, the first and the last looks because only they have been published.
All right.
This lecture answer.
Thank you for watching so far.
See you in the next lecture.