‫Welcome back.
‫Depending on parameters and return type, we have for lambda expression types with parameters and return
‫type with parameters and no return value, no parameters, but with return value, no parameters and
‫no return value.
‫We created before this lambda expression and we assign it to this variable called add.
‫And we learned that it took into the parameters integers, two integers and return value is of type
‫integer.
‫The second type is with parameters and no return value.
‫I'll create val add two and here I specify the parameters.
‫It's of type integers, the arrow, and here no return value and it's assigned to unit.
‫Unit is the return type in Kotlin, unit is similar to void in other languages, and signifies that
‫the lambda expression doesn't return any meaningful full value, so there is no return value equals
‫to a b, and this lambda expression will only print the addition of a and b, it will not return anything.
‫So if I try to print the add two, I need to call add two and pass the arguments five and five.
‫Run the program I get ten, but with Kotlin and dot unit.
‫And to get rid of this, just call the lambda expression that will print addition of five and five.
‫So println five plus five run.
‫And here we go eight and ten.
‫Let's move to the third type.
‫Here we have no parameters but with return value.
‫For example val add three no parameters and the arrow and it will return for us a string equals to.
‫Welcome to our course.
‫If I call add three like this.
‫Or I can add invoke method run nothing shown because it's returning type is a string and this method
‫returns a string.
‫We need to display the string.
‫So for that I need to include it inside the println function like this.
‫Run now and here we go.
‫It took no parameters and return a string.
‫The fourth type is no parameters and no return type.
‫For example, add four no parameters, no return type.
‫So I'll use unit which is void equals to print ln no parameters, no return value.
‫Then add four dot invoke.
‫Here I am using println so there is no need to include it inside println.
‫Run and here we go.
‫No params, no return value.
‫There's a small note that I should mention it.
‫You can direct use lambda expression in println or any other places.
‫For example print ln.
‫Here I'll create a lambda expression without assigning it to a variable and then calling this variable.
‫For example A it's of type int b it's of type int.
‫That gives us a times b.
‫And here I call the arguments four and five.
‫Here is the lambda expression.
‫And here are the arguments.
‫And I'm calling this lambda expression directly.
‫Then I'm specifying their arguments.
‫Run the program and we can get the value of 20 which is four times five included in this body of this
‫lambda expression.