There are so many fun things that can easily be done with Scala…this is one of the reasons I like it.
For example, here’s a class with an exposed method that takes as its params an Int, String and a block of code to run which can return anything the caller wants:
Now let’s make a class that depends on CoolClass and uses its method.
Now for some basic dependency injection in our main class:
Here’s a really easy way to test this code using the ScalaMock library.