Tutorial by Examples

A trait is a reusable set of methods and fields that can be added to one or more classes. trait BarkingAbility { String bark(){ "I'm barking!!" } } They can be used like normal interfaces, using implements keyword: class Dog implements BarkingAbility {} def d = new Dog() asser...
Class can implement multiple traits. In case if one trait defines method with the same signature like another trait, there is a multiple inheritance problem. In that case the method from last declared trait is used: trait Foo { def hello() {'Foo'} } trait Bar { def hello() {'Bar'} } cla...

Page 1 of 1