‫We learned about the anonymous function, and we said that it's a function without a name, and we learned
‫about its syntax.
‫Now let's learn about the types of anonymous functions.
‫We have four types depending on the parameters and the return value of the anonymous function with parameters
‫and return value with parameters and no return value, no parameters and return value, no parameters
‫and no return value.
‫I'll start with parameters and return value.
‫And we took about this type an example before, but I'll create a new example here for multiplication.
‫So val multiply equals to function a.
‫These are the parameters a and b and the return type is an int.
‫And here I specify the return keyword a times b.
‫This is our first type which is with parameters and and a return value.
‫Let me call this anonymous function.
‫You can use invoke method or you can write like this.
‫And you pass the parameters.
‫I need to print the result of six times six.
‫Let me run.
‫And here we have 36.
‫This is the first type.
‫The second type is with parameters and no return value.
‫I'll start with multiply two which is a variable equals two function.
‫And by the way I'm using the shorter syntax of this anonymous function a is of type int b.
‫It's of type int and no return value.
‫So I can specify unit here or I can omit it and directly write like this.
‫No return value.
‫So I need to print ln a times b.
‫Let me run and see this multiply two I'll pass four times five.
‫Run.
‫And here we go 20 is the result of four times five.
‫The third type is no parameters and return value.
‫For example val message equals to function no parameters.
‫So there are no parameters inside these parentheses.
‫And the return type is a string.
‫So it will return for us.
‫Welcome to our course.
‫Then when calling this anonymous function we will get this string as a return value.
‫So I can directly print and end the message.
‫And here I'm calling it as a function.
‫Let me run the program.
‫And here we go.
‫Welcome to our course.
‫The fourth type is no parameters and no return value.
‫For that I'll create message two variable equals to function no parameters and no return value.
‫No parameters, no return value.
‫Then I'm going to call message to anonymous function.
‫Let me run and here we go.
‫We get welcome again text.
‫In this video we learned about the four types of anonymous functions according to their parameters and
‫return values.