Hello and welcome to the golden programming language course in the previous session, we talked about
how to iterate over a slice in this session.
We want to talk about the either a splice concept.
At items, twist lies using Appin function.
Goal building package provides an app and function that can be used to appeal to a slice at the end.
Now you can see the syntax.
The first argument of the append function is this nice, it's sunny, the second is the variable number
of arguments, which is element ellipses type.
It's this operator, is there VIDEO The syntax, so basically and it's this type means that the append
function can accept variable number of arguments of type type.
Now go to the school program to illustrate how to add items to it's nice using app and function.
First, define this vice for the example, a column he could make function and sit the tight end and
lend his tool and copy satisfying.
Go to the next line and initialize it, slice a square brackets in big zero.
He calls for the example, 10, and in the next line, a square bracket index one equals 20.
Now, this very variable created if
this is a separate event.
Hey, and go to the next line and display lands and capacity off variable a if if!
The length.
Percent de Vegas, the city and Traverse City
following this and be like, is this an asset to function land and capacities here?
And and sit here aid and chat function for display the capacity of a very area.
Now we can add items to a slice by using athon function.
Go to the next line a equals attend function.
First, Barry is name of the variable and second variable is values and, for the example, set the
value 30 como 40, 50, 60, 70, 80 and 90.
OK, go to the next line and display the variable values again.
For the example, if p
this nice a after appending data
and set the very then a and go to the next line and display length and capacity of variable again,
if f the links person, the is T and capacity call in Person D and back is less and set to function
linear check land for a and chat function faucet.
The capacity for variable A now only format the save the project and execute the code.
Now we can see the output before we add new items.
It's nice e has to value 10 and 20 and length is too, and capacity is five.
And after appending data, it's noise.
Elements are 10 to 90 and length is nine and capacities 10.
If there is sufficient capacity in the underlying guest list, the element is placed after the last
element and the links get implemented.
However, if there is not sufficient capacity in meaningless noise is created, all of the existing
elements are copied over.
The new element is added on to the end and the nearest noise is returned in order not to prolong the
time of decision even will finish it, and we will continue the content in the next session.
Goodbye.