Ranges

Ali Çehreli acehreli at yahoo.com
Sat Aug 6 17:29:30 UTC 2022


On 8/6/22 09:33, Salih Dincer wrote:

 > the slices feel like ranges, don't they?

Yes because they are ranges. :) (Maybe you meant they don't have range 
member functions, which is true.)

D's slices happen to be the most capable range kind: RandonAccessRange. 
All of the following operations are supported on them as long as one 
imports std.array (or std.range, which publicly does so):

- empty
- front
- popFront
- save
- back
- popBack
- indexed element access

Slices have the optional length property as well (i.e. hasLength).

Those operations are not supported by member functions but by 
free-standing functions.

Ali



More information about the Digitalmars-d-learn mailing list