Hi this is really hard.
Once again welcome to the next video of this more duel of high level functions and Landau's.
Now this video is actually the continuation of the previous videos and in the previous videos we talked
about the point number 1 2 and 3.
Now it's time to proceed ahead and check out Vawter closures in case of Cartland And how does it is
compared to Java in Java 8.
You can not mutate or change the value of the outside variables inside the lambdas but in case of Cartland
you can simply change or mutate the values.
Now for those who have a big nose Let's check out an example and also check out Vawter closures in case
of Java and also Cartland.
So here inside the Indonesia ID I would simply make some changes.
I would simply combine the first two lines because one line is sufficient for this tutorial.
Sort of finding that Izard inside the two numbers.
They will do is simply define a variable of Brizard.
Let's see the sum is actually the result is initially 0.
Right now this is actually the outside variable that is for this lambda expression.
This variable razored is actually the outside variable that you cannot modify inside the function.
If you are using the lambdas in case of Java but in Cartland you have got the right to modify this result
from 0 to some value inside the lambda function such as we can write here.
That is equal to express vi like this.
But in Java you are not allowed to change the value of the desert that we are doing it here right now
here it shows some error because this expression as a whole does not return anything.
That is the expression starting from lizzard until VI does not return anything.
So here we can not have in your signature here.
So let us change it to unit.
Now if you uncomment these lines of code.
Then again you have to modify this to unit and here as a result equal to express why.
So as of now let's come back and now down the side near the spring.
That is a such as print line that is right and down the side.
This action actually DOES NOT returns anything because the return type is actually unit.
Right so there is no meaning of using value as a variable result equal to action because this action
does not return anything.
So if you are going to print this result down here it is going to give us some weird output.
Fine.
So as of now let us remove this variable result from here.
Also remove this statement because the print statement we have mentioned here right.
So when this dude will be executed then this dude will be replaced by this statement is equal to explicit
right.
So here there is equal to explicit Y means that it will be 9.
So the value of 9 will be stored inside that is.
So let us not check the output and see what happens.
So here we get 9 in the output console.
So remember this action in B will be replaced by this expression dessert equal to express y which simply
means razored equal to duplicity in with just 9.
And then we are simply printing.
That is Eric that is 9.
So always remember in Cartland we have got the right to modify the outside variable.
That is the closure.
So let's continue our discussion of lambda expression and the High-Level function in the next video
as well.
So catch you guys in the next video.
Thanks for watching.
Strings that are signing off.