1 00:00:00,690 --> 00:00:04,350 Ella one Welcome to this lecture him this lecture. 2 00:00:04,530 --> 00:00:13,350 I'll be explaining how the break loop statement works in Ruby programming language. 3 00:00:13,350 --> 00:00:17,360 What does a break loop to a break no. 4 00:00:17,390 --> 00:00:25,640 Basically is used to 10 minute loop airlifted to a 10 minute block within a loop. 5 00:00:25,920 --> 00:00:30,860 So it can be used with a while loop and also with you. 6 00:00:30,870 --> 00:00:37,270 For now let's look at a typical example of how the break loop works. 7 00:00:37,360 --> 00:00:41,030 So this is a variable quoll X.. 8 00:00:41,220 --> 00:00:49,440 So while the condition is true it will output X and this time it output X it will increase the value 9 00:00:49,440 --> 00:00:56,850 to one or it will break out of the loop when X becomes greater than 5. 10 00:00:56,880 --> 00:00:59,450 So let's see how that works. 11 00:00:59,490 --> 00:01:08,430 I have caught the interactive Ruby screen open so I am going to create a variable called X and I went 12 00:01:08,430 --> 00:01:17,880 to set that to equal so the value of syrup I'm going to implement a while loop as a condition. 13 00:01:17,920 --> 00:01:19,640 Went as well. 14 00:01:20,010 --> 00:01:23,670 My condition is true. 15 00:01:24,000 --> 00:01:25,090 I want you. 16 00:01:25,140 --> 00:01:41,190 I want the code to do what's in the code block so I want it to output the value of x K and each time 17 00:01:42,690 --> 00:01:44,850 he checks the condition. 18 00:01:45,630 --> 00:01:53,400 I want the value of x to increase this plus minus 1 means that each time the loop checks the condition 19 00:01:53,460 --> 00:01:58,930 it will increase the value of x by 1. 20 00:01:59,430 --> 00:02:02,720 So here I'm going to apply the brake. 21 00:02:03,150 --> 00:02:13,730 So I want the loop I want the look to break if the condition I set in the break statement becomes true. 22 00:02:13,950 --> 00:02:21,180 Some say if X becomes greater than say 7. 23 00:02:22,830 --> 00:02:26,150 I want the rope loop to break. 24 00:02:26,370 --> 00:02:27,890 So what does it all. 25 00:02:27,900 --> 00:02:29,190 Check the condition. 26 00:02:29,220 --> 00:02:33,370 It will output one go again. 27 00:02:33,380 --> 00:02:41,700 Checked the condition and will have to keep going until it gets to 7 when it gets to 7. 28 00:02:41,700 --> 00:02:49,290 It will break because it will now become greater than 7 so the condition within the break is that the 29 00:02:49,290 --> 00:02:57,350 loop can keep going on till X is low no longer less than 7 once X becomes greater than 7. 30 00:02:57,390 --> 00:03:02,900 We want the loop to break so lets me run that look and see and see. 31 00:03:02,910 --> 00:03:07,770 So the first time he checks the condition this is your original value zero. 32 00:03:07,890 --> 00:03:09,140 So it goes round. 33 00:03:09,140 --> 00:03:10,340 Check it again. 34 00:03:10,680 --> 00:03:12,280 The condition is too true. 35 00:03:12,320 --> 00:03:20,340 He had one goes round again as another keeps adding it to keep output in the value of x keeps changing 36 00:03:20,870 --> 00:03:24,350 on till X becomes greater than 7. 37 00:03:24,360 --> 00:03:30,250 It had to stop here because if he was 8 it would become greater than 7. 38 00:03:30,420 --> 00:03:36,470 So that's how a brick works in a nutshell so you can use brakes. 39 00:03:36,780 --> 00:03:42,190 Are there types of look if you want to break out of the loop condition. 40 00:03:42,450 --> 00:03:44,310 So that's it for this lecture. 41 00:03:44,370 --> 00:03:46,060 Thanks by for an app.