1 00:00:01,980 --> 00:00:03,200 Hi this is really hard. 2 00:00:03,210 --> 00:00:08,490 Once again welcome to the next video of this more duel of high level functions and Landau's. 3 00:00:08,520 --> 00:00:15,120 Now this video is actually the continuation of the previous videos and in the previous videos we talked 4 00:00:15,120 --> 00:00:18,130 about the point number 1 2 and 3. 5 00:00:18,160 --> 00:00:24,910 Now it's time to proceed ahead and check out Vawter closures in case of Cartland And how does it is 6 00:00:24,960 --> 00:00:28,080 compared to Java in Java 8. 7 00:00:28,110 --> 00:00:35,940 You can not mutate or change the value of the outside variables inside the lambdas but in case of Cartland 8 00:00:36,030 --> 00:00:39,110 you can simply change or mutate the values. 9 00:00:39,300 --> 00:00:45,450 Now for those who have a big nose Let's check out an example and also check out Vawter closures in case 10 00:00:45,450 --> 00:00:48,040 of Java and also Cartland. 11 00:00:48,240 --> 00:00:52,590 So here inside the Indonesia ID I would simply make some changes. 12 00:00:52,590 --> 00:00:58,700 I would simply combine the first two lines because one line is sufficient for this tutorial. 13 00:00:58,830 --> 00:01:01,920 Sort of finding that Izard inside the two numbers. 14 00:01:01,980 --> 00:01:06,810 They will do is simply define a variable of Brizard. 15 00:01:06,930 --> 00:01:11,430 Let's see the sum is actually the result is initially 0. 16 00:01:11,550 --> 00:01:18,070 Right now this is actually the outside variable that is for this lambda expression. 17 00:01:18,120 --> 00:01:25,410 This variable razored is actually the outside variable that you cannot modify inside the function. 18 00:01:25,470 --> 00:01:31,830 If you are using the lambdas in case of Java but in Cartland you have got the right to modify this result 19 00:01:32,160 --> 00:01:38,030 from 0 to some value inside the lambda function such as we can write here. 20 00:01:38,250 --> 00:01:42,000 That is equal to express vi like this. 21 00:01:42,000 --> 00:01:49,290 But in Java you are not allowed to change the value of the desert that we are doing it here right now 22 00:01:49,470 --> 00:01:54,900 here it shows some error because this expression as a whole does not return anything. 23 00:01:55,050 --> 00:02:00,890 That is the expression starting from lizzard until VI does not return anything. 24 00:02:00,900 --> 00:02:04,860 So here we can not have in your signature here. 25 00:02:05,010 --> 00:02:07,880 So let us change it to unit. 26 00:02:07,980 --> 00:02:10,850 Now if you uncomment these lines of code. 27 00:02:10,890 --> 00:02:17,300 Then again you have to modify this to unit and here as a result equal to express why. 28 00:02:17,430 --> 00:02:23,190 So as of now let's come back and now down the side near the spring. 29 00:02:23,220 --> 00:02:29,960 That is a such as print line that is right and down the side. 30 00:02:29,990 --> 00:02:35,730 This action actually DOES NOT returns anything because the return type is actually unit. 31 00:02:35,810 --> 00:02:43,760 Right so there is no meaning of using value as a variable result equal to action because this action 32 00:02:43,760 --> 00:02:45,310 does not return anything. 33 00:02:45,320 --> 00:02:50,960 So if you are going to print this result down here it is going to give us some weird output. 34 00:02:51,050 --> 00:02:51,550 Fine. 35 00:02:51,710 --> 00:02:55,970 So as of now let us remove this variable result from here. 36 00:02:55,970 --> 00:03:01,370 Also remove this statement because the print statement we have mentioned here right. 37 00:03:01,670 --> 00:03:08,600 So when this dude will be executed then this dude will be replaced by this statement is equal to explicit 38 00:03:08,600 --> 00:03:09,040 right. 39 00:03:09,260 --> 00:03:16,500 So here there is equal to explicit Y means that it will be 9. 40 00:03:16,580 --> 00:03:19,610 So the value of 9 will be stored inside that is. 41 00:03:19,790 --> 00:03:23,280 So let us not check the output and see what happens. 42 00:03:23,300 --> 00:03:26,350 So here we get 9 in the output console. 43 00:03:26,390 --> 00:03:32,810 So remember this action in B will be replaced by this expression dessert equal to express y which simply 44 00:03:32,810 --> 00:03:36,150 means razored equal to duplicity in with just 9. 45 00:03:36,320 --> 00:03:37,730 And then we are simply printing. 46 00:03:37,730 --> 00:03:39,430 That is Eric that is 9. 47 00:03:39,680 --> 00:03:45,290 So always remember in Cartland we have got the right to modify the outside variable. 48 00:03:45,350 --> 00:03:46,820 That is the closure. 49 00:03:47,180 --> 00:03:52,820 So let's continue our discussion of lambda expression and the High-Level function in the next video 50 00:03:52,820 --> 00:03:53,690 as well. 51 00:03:53,690 --> 00:03:55,470 So catch you guys in the next video. 52 00:03:55,520 --> 00:03:56,550 Thanks for watching. 53 00:03:56,640 --> 00:03:57,890 Strings that are signing off.