Search⌘ K

Use of Slices as Ranges

Explore how slices in D can act as powerful RandomAccessRange objects when you import std.array. Learn to utilize range functions such as empty, front, and popFront with slices, understand the limitations of fixed-length arrays as ranges, and how to copy elements into arrays using the array helper function. This lesson helps you handle data flexibly using ranges to write clearer and more efficient D code.

We'll cover the following...

The std.array module to use slices as ranges

Merely importing the std.array module makes the most common container type conform to the most capable range type; slices can seamlessly be used as RandomAccessRange objects.

The std.array module provides the functions empty, front, popFront() and other range functions for slices. As a result, slices are ready to be used with any range function, for ...