Use of Ranges in D

Let’s look at the use of ranges in D in this chapter.

Ranges are an integral part of D

D’s slices happen to be implementations of the most powerful range RandomAccessRange, and there are many range features in Phobos. It is essential to understand how ranges are used in Phobos.

Note: Phobos is the standard run time library for D. Many Phobos algorithms return temporary range objects. For example, filter(), which chooses elements that are greater than 10 in the following code, actually returns a range object, not an array:

Get hands-on with 1000+ tech skills courses.