Ranges

Salih Dincer salihdb at hotmail.com
Sun Aug 7 17:30:47 UTC 2022


On Sunday, 7 August 2022 at 15:34:19 UTC, pascal111 wrote:
> Everyone knows that slices are not pointers that pointers are 
> real work, but slices are like a simple un-deep technique that 
> is appropriate for beginners, but after that in advanced level 
> in programming, we should use pointers to do same tasks we were 
> doing with slices (the easy way of beginners).

The following information about slices may be helpful:

> Slices are objects from type T[] for any given type T. Slices 
> provide a view on a subset of an array of T values - or just 
> point to the whole array. Slices and dynamic arrays are the 
> same.
>
> A slice consists of two members - a pointer to the starting 
> element and the length of the slice:
> ```d
> T* ptr;
> size_t length; // unsigned 32 bit on 32bit, unsigned 64 bit on 
> 64bit
> ```
> [...]
**Source:** https://tour.dlang.org/tour/en/basics/slices

SDB at 79


More information about the Digitalmars-d-learn mailing list