Traits

This lesson introduces you to traits.

When there are multiple different types behind a single interface, the interface can tell which concrete type to access. This is where the traits come in handy.

What Are Traits?

Traits are used to define a standard set of behavior for multiple structs.

They are like interfaces in Java.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy