How to use Groovy Traits

Traits are reusable components basically set of methods or fields that you can make your class implement.
 
Why you should use them ?
You must have heard of problems of multiple inheritence when working with java and also familiar with the well known situation of what is know as ‘Diamond problem’.It says that if you have two classes B and C inherit from A, and class D inherits from both B and C. If there is a method in A that B and/or C has overridden, and D does not override it, then which version of the method does D inherit: that of B, or that of C ??
via How to use Groovy Traits.

Leave a Reply

Your email address will not be published. Required fields are marked *