Hello and welcome to the gold and programming language course in this session.
We want to talk about adding, updating and deleting items.
Act.
In maps, you're allowed to key value Perth in the initialized map using the given syntax.
Now you can see the syntax.
Update in maps.
If you try to end an already existing key, then it will simply overwrite or update the value of that
key within the nil value.
And delete the built in delete function, deletes an item from a given man associated with the provided
key.
You can see the syntax for delete function.
Now go to the school program to illustrate how to map adding, updating and deleting items.
First, creating and initializing a map to a person's ideas.
My Mac.
Equals nap time index is in and value type is a string and initialized by values 10 column, 14
and 20 column for gene, said Comma.
Go to the next line 30 column for the rather
40 column value at long.
And the end element 50, Colin, and the value for the example of Sophia.
Now display the created math.
P
my ma I said that I needed my.
Reformat the code and save the causes first, we created man initialize it and display it now, adding
new key value pairs in the map.
Go to the next line and follow the example in my mapped set index 60 and initialize it by the value
for the example jack.
Go to the next line and define another element.
My Map Set Index 70 and initialize it by Julia.
Go to the next line and display our map again because the map element has changed.
If P my map after adding.
New elements.
And sit my about it.
Before the call, save the project and execute, they could.
Now we can see the output before adding elements.
My map variables has values.
10 gene to gene church Robert, 44, and 50 Sophia.
And after adding two variables, my map variables has values 10 gene, 20 Gene 30 Robert, 48, want
50 Sufian and 60 Jack and 70 Julia.
Now we could add new items to our map.
Go to updating values of the map and initialize new values to existing index.
For example, in the 20s exist and we change its value.
Go to the code
my Mac Index 20 and change its values.
To follow the example Diego, go to the next line and again display the variable values FP Mind now,
after changing
values and set the values in my map, said the project.
An easy commute again.
Now we can see the output and we could change index to value from Jean to Diego.
Now go to delete an element from that.
Go to quote
now, use from delete function.
This function has two parameters.
First is name of your mat at second is index of element that you want to delete it for the example that
you want to remove Index 50 and its values from Mac go to display the man again.
This is my math after deleting Index 50 and certainly
reformat the code and say the project and execute again the program.
Now, we can't see the output index 50 and its value has deleted from our map.
Okay.
We could add new items in map update existing elements by index and delete existing elements by the
Delete Function Index in our map.
In order not to prolong the time of decision, we'll finish it and we will continue the content in the
next session.
Goodbye.