1 00:00:00,600 --> 00:00:02,980 Hello and welcome to this lecture. 2 00:00:03,090 --> 00:00:11,310 In this lecture I will be explaining what Rangers are in the Ruby programming language. 3 00:00:11,820 --> 00:00:18,690 What is a range a range represents an interval. 4 00:00:18,690 --> 00:00:27,800 So you can think of a range that is a set of values that has a beginning and an end. 5 00:00:28,260 --> 00:00:34,590 There are two main types of raindance we've got inclusive rents. 6 00:00:34,830 --> 00:00:43,600 Example one to 10 new Kin identify the ranges for example with the inclusive range to identify you do 7 00:00:43,620 --> 00:00:52,840 two dots because he hear one and then dot dot to identify the type of ring. 8 00:00:53,020 --> 00:00:55,410 We have an inclusive range. 9 00:00:55,470 --> 00:01:05,670 It will keep you a list of all the numbers within the ranks while the other type of ranges quad exclusive 10 00:01:06,170 --> 00:01:10,410 with their school to see if you can identify that with three dots. 11 00:01:10,560 --> 00:01:14,500 And the last value is often exclude it. 12 00:01:14,790 --> 00:01:20,320 So the best way to illustrate this is to show you examples. 13 00:01:20,320 --> 00:01:27,150 I have got my ruby interactive interactive Ruby So I'm doing the typing here range. 14 00:01:27,200 --> 00:01:34,010 I'm going to typing on one dot dot 10 that should return the same thing. 15 00:01:34,590 --> 00:01:35,080 Okay. 16 00:01:35,100 --> 00:01:45,630 Next time I'm going to create a variable quote X and assign it that value dot dot 10 which means I'm 17 00:01:45,630 --> 00:01:48,140 dealing with an inclusive range. 18 00:01:48,630 --> 00:01:52,620 All right so that has given me the same value. 19 00:01:53,040 --> 00:02:03,620 I'm going to attach a class to that and that should reveal that is a range as told me that is a range. 20 00:02:03,690 --> 00:02:05,230 So it ranges. 21 00:02:05,280 --> 00:02:09,700 You can retrieve the beginning and the end. 22 00:02:09,780 --> 00:02:14,220 I wanted to find out what the first value of that range is. 23 00:02:14,400 --> 00:02:19,680 So I'll do X which is a variable dot begin. 24 00:02:21,120 --> 00:02:28,130 And that would give me the first value from that range. 25 00:02:28,580 --> 00:02:39,640 If I want to see the last value from that range do X Darte ENT and that should give me a value of 10. 26 00:02:40,670 --> 00:02:43,580 There's another command you can use which is similar. 27 00:02:43,580 --> 00:02:45,690 You can do X.. 28 00:02:46,040 --> 00:02:55,820 First week me and give me the first value that you give me one and then x at last. 29 00:02:55,910 --> 00:02:58,700 That should give you 10. 30 00:02:58,740 --> 00:03:05,350 Let's create another variable this time to illustrate the exclusive range. 31 00:03:05,450 --> 00:03:14,810 So I'm going to create a variable called Y and went to set that to an exclusive range do 1 and it would 32 00:03:14,810 --> 00:03:25,780 be 3 dots dot dot dot and 10 and that will return that rightly again to retrieve the first value. 33 00:03:26,090 --> 00:03:29,500 Do y not begin. 34 00:03:29,510 --> 00:03:35,700 That should give me one hand to retrieve lao's value. 35 00:03:35,870 --> 00:03:41,930 You would expect in 9 because with an exclusive range it doesn't. 36 00:03:42,090 --> 00:03:48,590 It excludes the last value but this will also reveal the 10. 37 00:03:48,850 --> 00:03:52,630 So do Y don't. 38 00:03:53,410 --> 00:03:57,160 It should give me 10 whole damn expect in a night. 39 00:03:57,500 --> 00:03:59,340 So is giving me 10. 40 00:03:59,460 --> 00:04:01,830 Sometimes you don't get accurate. 41 00:04:02,090 --> 00:04:08,900 It doesn't give you an accurate reading from here but there is a way you can find out for sure. 42 00:04:09,170 --> 00:04:11,820 And the way to do that you can do. 43 00:04:11,940 --> 00:04:17,960 Let me do the x variable first so x don't include 44 00:04:21,770 --> 00:04:28,900 questionmark and then empathises are say 10. 45 00:04:29,480 --> 00:04:33,370 So if X does include 10 it will return true. 46 00:04:33,770 --> 00:04:41,560 If I do the same for the Y you would see that it will give a false value. 47 00:04:41,910 --> 00:04:44,170 K question mark. 48 00:04:45,730 --> 00:04:57,820 I expect if they say is written force because with this type of range it should exclude the last letter 49 00:04:57,910 --> 00:05:00,850 or the last number in the ring. 50 00:05:00,850 --> 00:05:05,440 You can also list every thing within the ranks. 51 00:05:05,440 --> 00:05:12,400 For example I'm going to create another variable called zet and I won't to that two equals two. 52 00:05:12,870 --> 00:05:23,810 Well I use Harry here and I'm going to put this serifs symbol and then pass in the variable X.. 53 00:05:24,160 --> 00:05:30,640 And that should list all the numbers within that range as you can see. 54 00:05:30,640 --> 00:05:37,940 And you can do the same with the Y variable has what if you want to list all the numbers within the 55 00:05:37,960 --> 00:05:38,460 range. 56 00:05:38,590 --> 00:05:46,420 So this was just a brief lecture just to introduce you to the concept of a range in the Ruby programming 57 00:05:46,600 --> 00:05:47,620 language. 58 00:05:47,950 --> 00:05:55,140 This you may come across as you begin to develop applications in Ruby. 59 00:05:55,150 --> 00:05:57,560 Thanks for watching and bye for now.