100. Traits and interfaces
As Groovy’s interfaces don’t support default implementations it may be tempting to favour traits. This isn’t a good idea and you should try to describe interactions within your code and with other developers via an API described in interfaces.
Once you’ve described your interface, a trait can implement the interface in the same manner as classes do, through the use of the implements keyword:
interface Locomotion {
String getDescription()
}
trait Hopping implements Locomotion {
@Override
String getDescription() {
'hop hop hop'
}
}