AI Features

Writing Our Own Interfaces II

Let’s learn how to implement sort.Interface for 3D shapes.

Implementing sort.Interface for 3D shapes

In this lesson, we will create a utility for sorting various 3D shapes based on their volume, which clearly illustrates the power and versatility of Go interfaces. This time, we will use a single slice for storing all kinds of structures that all satisfy a given interface. The fact that Go considers interfaces as data types allows us to create slices ...