Value Types vs Reference Types

In this lesson we will see how D's arrays and slices behave with value type and reference type. Furthermore, we will perform an experiment to apply == operator to different types.

Fixed-length arrays and slices #

D’s arrays and slices show different behavior when it comes to value type versus reference type.
As we have already seen above, slices are reference types. On the other hand, fixed-length arrays are value types. They own their elements, behaving as individual values:

Get hands-on with 1200+ tech skills courses.