O'Reilly logo

Learning Scala Programming by Vikash Sharma

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Traits as stackable modifications

Before we learn about stackable modifications, we should know why we may need them, shouldn't we? Yes, so the best way to understand that is by using an example. Suppose there's a consumer of a service. He can pay to subscribe to a particular service. That service, for example your DTH TV subscription service, includes several channel packages. Now, what's of interest to us here is that we may want to implement this service. For implementation, we want to have a list of channels or packages the consumer is subscribed to. At the beginning of the month, he subscribed to a particular package, let's say BasicPackage. So we said the following:

new Service with BasicPackage 

This, in fact is self-explanatory. We ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required