tezvyn:

Explain and implement a Kotlin higher-order function

Source: kotlinlang.orgintermediate

Tests understanding of first-class functions and lambda usage. First, define a higher-order function (HOF) as one that takes/returns functions. Then, implement the requested function, iterating to apply the predicate and transform.

This tests your grasp of functional programming in Kotlin. Can you define a higher-order function (HOF) and then write one using lambdas? A great answer first defines a HOF as a function taking functions as parameters or returning one. Then, implement `filterAndTransform` by creating a new list, iterating the input, applying the predicate, and if true, applying the transform and adding the result. A red flag is implementing the function with a loop but failing to explain the core concept of functions as first-class citizens.

Read the original → kotlinlang.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Explain and implement a Kotlin higher-order function · Tezvyn