Hello and welcome.
In this lecture I'm going to explain how the for loop works in the Ruby programming language.
What does a four loop do for a loop.
Basically it is use when the number of iterations is known before it enters the loop.
What that means is that the present value of a for loop is the value iterated over on less.
A break is you some time with any form should be put in a loop you can use a break to break the loop.
So what this is saying is there's no break.
There is someone family for the four look.
Is in value iterated over.
So we're going to see how that works.
Also a for loop is like it will happen that you don't have to use the to do option is optional you don't
need to use the key word for looks is rarely use in modern Ruby programs.
So let's look at.
He'd be a syntax.
So we've got a 4 key word followed by airable which could be Hillary and then you won't be on clits
in the hurry.
The for loop will iterate.
True and that based on the expression you set it to execute what I could.
In that block and then the statement ends.
So let's see how that works.
I have got my interactive Ruby first and I want to do is define an array.
I'll say Hey Jake was too.
I've seen one to three.
Four five six seven.
Are close.
Mary and the arrow is now closed.
We've got a very there or seven up.
So I'm going to use a for loop to iterate.
True.
Remember a for loop basically knows what he's going to eat right before he goes into the loop.
So one time went up and went to see x 4 to define a for loop for X..
In that.
We know the area has got seven outlets.
I'm just going to list all of them.
Here's two three four five three.
Seven.
So we've got all the members on that Arey that the value that X is going to loop through then here is
where we'll put the statement they could.
They're all executed.
So what I want I want it to.
I just wanted to add put the value of that x.
So how it goes to the Aries I want it to list the objects in that hurry so I just see it if I press
end now and press enter it should list all the members of that Hurry.
As you can see it's listed all of them so there's busiek we.
How a fawn Look works.
Thanks for watching.
Bye for now.