In one of my previous post about Traits in Scala, I have pointed out one sentence that abstract classes and traits in Scala are Stackable. So what does that mean? Let me elaborate a bit on that part.
In my earlier post related to Traits in Scala, I have mentioned one point regarding limiting the access of trait to any class in Scala. Yes, it is possible in Scala to limit a trait such a way that it can be extended by very specific sub classes.
We all might know about Java Interfaces. Traits in Scala are very much similar to Java Interfaces. There is just one exception if we compare traits with interfaces in Java (Java 7 and earlier version) and that is traits can also have methods with implementation. Let’s look from different perspective. In Scala we can treat traits same as classes which doesn’t have constructors with parameters.