Scala code fluency with functional composition
Would you like to see an example on how to use Scala 'andThen'? If so, read along.
This article will discuss the usage of functional composition in Scala to achieve concise and fluent code. It will demonstrate how code can evolve from a naïve approach to a fluent one. Scenario We’ll write code that describes how to make pizza which consists of the following steps: Mixing ingredients to make the dough Kneading the dough to turn it into smooth dough Rolling out the smooth dough to make the base Adding toppings on the base to make the base with toppings Baking the base with toppings to produce the final product, pizza In a nutshell, the steps above must be performed in this predefined sequence to work. [Read More]