Wednesday, August 7, 2019

Kotlin in Action: Chapter 8 Exercises

Chapter 8 covers higher order functions, which is just a fancy way of saying functions that can take a function as a parameter or return a function (or both). it also covers other points such as inline functions, non local returns, and many other such points.

Exercise: Filter Out

So for a simple exercise to test our knowledge out, let's create a method that takes in a lambda. We'll create a filterOut method, which works similarly to the filter method, but instead of keeping anything that matches the predicate, it will remove anything that matches the predicate, and keep everything else.

As usual, an answer will be given in a follow up post. And the answer can be found here.