A Null Object is an object that extends a base type with a null or neutral behavior. Here’s the Scala version of the Java example Wikipedia uses to demonstrate this:
trait Animal {
def makeSound()
}
class Dog extends Animal {
def makeSound() { println("woof") }
}
class NullAnimal extends Animal {
def makeSound() {}
}
As you can imagine, later in your application you might have some code like this: