hey guys what's going out and square ticking and in this lecture, we're going
to learn about the beach for if loop(Dallas Website Development) the for each loop is used to look through and associate embrace so inside the break is here we have our so she to a
follow that by the going as and then we have our Niki which we can start
inside of a key variable full so that by the rocket operator and then the
risky value which we can story people called value now the key and value
variables can be named anything as long as you remember that this one refers
to the and that this one refers to the risk of out for you and just to
review this is what they're so she to a very looks like the key made with
refer to them in this example and the value variable would refer to the key
the value which is twenty-three so that's the syntax of the for each flip now
the loop is going to end when the final key valley Paris it's so in our
the example here one german forty-two key valley there has been reached the loop
is going to end [NOISE] that's it for the syntax now let me show you a
a practical example I'm going to go ahead and create a new era here and of
animals and always going to be is by having animal names along with this
sounds those animal meaning those the more make so I'm going to create from
bad as [UM] ~~~~~~~ [COUGH] lawyers [UM] of ads some biennials care [COUGH]
health and hunger and culture [SMACK] was streamed the animal named here is
the key and the area value is the sound that this animal makes so I'm going
to go ahead and looked through the animals a now [UH] if you can see I made
my variables name and sound because it makes sense inside of our animals we
will have the animal name and this is what the names are referring to its
referring to their the key of the area and the sound is your for into the
valley of the rain so if I these two here and I use a space that can cat age
you together and then at the and I'm going to use the art make it look nice
or this is exactly was going to print out they're going to print out the
animal name and then space and the sound which the animal makes so as you
can see here there or is expected we're looking through their so she too
marry and it springs now at the art and the arrow value now I'm an all turn
as a way to write this would be as follows you can just use the associate
of a raw name and since who have access to the key this whole give us the
valley of the right and so now we have all the valley is not a way to write
this is to completely avoid this part and if we wanted to just print out the
arrow values who can do so in this way as well so this the same exact thing
as before so that's it for this example and now I want to show you something
else I want to show you how to money my area valleys by a reference so for
an example he found that renamed numbers and was going to keep the short and
put find numbers and year and then I looked through this area numbers are in
the short version because only need values were going to print out this radio
the most and the numbers if all the name and so right now has just printing
out there a and we have a key we have a value have a key you have a valley
so you can see that the all the valley as one two three four five now if we
wanted to directly modify those valleys here's what we can do and this is
called dietary valleys by the reference he would simply put the emperor sense
and from the air key and then we can say something like numbers equals i
mean number eagles I'm very times to and that would modify the three
a valley is so now all the all the valleys inside of the area would be doubled
so if I print out the area down here now

No comments:
Post a Comment