The Strategy pattern is a useful pattern for encapsulating algorithms, or pieces of algorithms, in self-contained units of computation, and which then enable your code to delegate to those encapsulated strategies when needed. In this section, we'll take a look at how higher-order functions in Kotlin can make the Strategy pattern easier to implement.
Revisiting the Strategy pattern in Kotlin
Understanding the Strategy pattern
How should two objects be compared when sorting? What action should be performed when a game controller's button is pressed? How should a computer-controlled player choose which chess piece to move? All of these questions are examples of problems where the Strategy pattern could be applied to...