10. Mixins

Overview

Mixins are a mechanism to group a set of zero or more slots for reuse through inheritance. Mixins are like Java/C# interfaces, but can contain concrete methods:

Mixins are declared using the mixin keyword:

mixin MyNewMixin {}

To understand how mixins actually work under the covers, take a look at the tour on mixins to see how mixins might look if translated to Java.

Mixin Modifiers

Mixins can be annotated with the public or internal modifiers just like classes.

A mixin can be declared with the const modifier which requires that any class using it must also be const.

It is a compile time error to use the abstract or final modifier with a mixin.