Higher-order functions in Kotlin

Updated 2 April 2018

Save

In this blog we are going to cover higher-order functions in kotlin with example. Higher order function can be passed as a parameter or can be returned from a function, the function which does the same is known as a higher-order function. In other words, a higher-order function is a function that takes functions as parameters or returns a function.

What is a Higher Order Function?

A higher-order function is a function that can take other functions as parameters and returns other functions.

How to create a Higher Order Function?

You can create a higher order function like any other function in Kotlin, but you need to create an parameter that has a function as the type.

Let’s take an example:

OUTPUT:  hellohellohello

Here, highOrderFunctionCall() is a function which take twoParameters() function as parameter.

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home