The command design pattern is another example of a design pattern that can be implemented differently in Scala compared to other languages. We will show another implementation of the preceding example. This time, we will use the by-name parameters feature of the language. It is replaceable with passing functions as parameters (something we've already seen before for the strategy design pattern), but more verbose. Let's see what it will look like.
Not much of the application actually has to change. We've only refactored and renamed the RobotController and RobotExample classes. Here is the former class, now called RobotByNameController:
class RobotByNameController { val history = ListBuffer[() => Unit ...