Hello and welcome to this lecture.
In this lecture I will be explaining what Rangers are in the Ruby programming language.
What is a range a range represents an interval.
So you can think of a range that is a set of values that has a beginning and an end.
There are two main types of raindance we've got inclusive rents.
Example one to 10 new Kin identify the ranges for example with the inclusive range to identify you do
two dots because he hear one and then dot dot to identify the type of ring.
We have an inclusive range.
It will keep you a list of all the numbers within the ranks while the other type of ranges quad exclusive
with their school to see if you can identify that with three dots.
And the last value is often exclude it.
So the best way to illustrate this is to show you examples.
I have got my ruby interactive interactive Ruby So I'm doing the typing here range.
I'm going to typing on one dot dot 10 that should return the same thing.
Okay.
Next time I'm going to create a variable quote X and assign it that value dot dot 10 which means I'm
dealing with an inclusive range.
All right so that has given me the same value.
I'm going to attach a class to that and that should reveal that is a range as told me that is a range.
So it ranges.
You can retrieve the beginning and the end.
I wanted to find out what the first value of that range is.
So I'll do X which is a variable dot begin.
And that would give me the first value from that range.
If I want to see the last value from that range do X Darte ENT and that should give me a value of 10.
There's another command you can use which is similar.
You can do X..
First week me and give me the first value that you give me one and then x at last.
That should give you 10.
Let's create another variable this time to illustrate the exclusive range.
So I'm going to create a variable called Y and went to set that to an exclusive range do 1 and it would
be 3 dots dot dot dot and 10 and that will return that rightly again to retrieve the first value.
Do y not begin.
That should give me one hand to retrieve lao's value.
You would expect in 9 because with an exclusive range it doesn't.
It excludes the last value but this will also reveal the 10.
So do Y don't.
It should give me 10 whole damn expect in a night.
So is giving me 10.
Sometimes you don't get accurate.
It doesn't give you an accurate reading from here but there is a way you can find out for sure.
And the way to do that you can do.
Let me do the x variable first so x don't include
questionmark and then empathises are say 10.
So if X does include 10 it will return true.
If I do the same for the Y you would see that it will give a false value.
K question mark.
I expect if they say is written force because with this type of range it should exclude the last letter
or the last number in the ring.
You can also list every thing within the ranks.
For example I'm going to create another variable called zet and I won't to that two equals two.
Well I use Harry here and I'm going to put this serifs symbol and then pass in the variable X..
And that should list all the numbers within that range as you can see.
And you can do the same with the Y variable has what if you want to list all the numbers within the
range.
So this was just a brief lecture just to introduce you to the concept of a range in the Ruby programming
language.
This you may come across as you begin to develop applications in Ruby.
Thanks for watching and bye for now.