Using Mixins

This lesson will help you learn about implementing.

Using Mixins

In this lesson, you will learn to use mixins to implement shared behavior(s) without inheritance.

Syntax

The B is the parent class to A. The C is the mixin with methods that B is interested in implementing.

class A extends B with C {
    //Implement methods from B & C
}

The Sketching behavior is shared between Artist and Engineer. Both extend the Person class. In this case, both Artist and Engineer can extend Person along with mixing shared behavior from Sketching class using the with keyword.

Refer to object-oriented class hierarchy to understand the relationship between people and their behaviors.

Get hands-on with 1200+ tech skills courses.