All right, so in the next couple of videos, we are going to use a bunch of lambda expressions, and
in general, it's a good idea for you to understand Lumba expressions in more depth because we have
covered them, but really just a tiny bit.
And now we're going to see the different aspects of lambda expressions and how they are used and the
advantages and so forth.
So I'm going to go over that in this presentation, but then we're going to use it extensively in the
room database demo as well as in the rest of the course, basically.
So let's look at CoQ10 lambdas.
So lenders are popular in different programming language, and they are well known for, for example,
being simple and concise way to create functions.
Then they are also known as functions with no name because you can just add implementations within its
block, and then they are also used to parse functions as parameters to other functions.
So let's look at this.
So there are various ways to create a lambda function, depending on the requirements.
One is as a parameter, for example.
So you see, we have first the variable name, then a column with the parentheses for the parameter
and then an arrow with a return type.
And here's an example with some as the variable in the integer parameter named result and a unit return
type, which means it's going to return nothing.
So this is like a void function that you would see in Java, for example.
So in this example here, the arithmetic class has a lambda declared in its constructor with an integer
parameter and a Boolean return type.
And then in the end, its block of the class we pass a value five once the class is initialized.
So we see this is again using a lambda and this time as a parameter.
So you can basically use one does at all different kinds of points of your application.
So another way can be to call a number within a block using the Invoke operator.
So here in this way, we call the method when the button is clicked and you can receive this value at
the point of initializing the arithmetic class.
So we are invoking or calling the same function right here with the value of five, so we're passing
five to it.
So it's here, this some.
OK, now to actually parse an argument or implementation of the lambda, we use curly braces.
So in this arithmetic class will receive the result passed in the init block and then check if the value
is greater than five because it has a Boolean return type.
We have a true or false at the end of each condition block here as well.
So we can also create a method first and then call it with the lumber.
So you see we have this method operation at the top and then we call it using a lambda at the bottom.
OK, so this was all rather theoretical.
Now let's go ahead and see how we can use lambdas in real world examples, in particular in our room
database example.