As with the other design patterns, this one has an implementation that takes advantage of the richness of Scala and uses some of the concepts we looked at throughout the initial chapters of this book. The decorator design pattern in Scala is also called stackable traits. Let's see what it looks like and how to use it. The InputReader and AdvancedInputReader code will remain exactly as shown in the previous section. We are actually reusing it in both examples.
Next, instead of defining an abstract decorator class, we will just define the different reader modifications in new traits as follows:
trait CapitalizedInputReaderTrait extends InputReader { abstract override def readLines(): Stream[String ...