On 1/19/23 10:34 PM, Ruby The Roobster wrote:
On Friday, 20 January 2023 at 03:30:56 UTC, Steven Schveighoffer wrote:
On 1/19/23 10:11 PM, Ruby The Roobster wrote:
...

The point is to be a range over the original input, evaluated lazily. Using this building block, you can create an array, or use some other algorithm, or whatever you want. All without allocating more space to hold an array.


I get the point that it is supposed to be lazy.  But why are these basic cases not implemented?  I shouldn't have to go write a wrapper for something as simple as casting this type to the original type.  This is one of the things that one expects the standard library to do for you.

A range simply does not provide the API you are seeking. It provides 3 methods:

front
popFront
empty

That's it. It does not provide appending. If you want appending or random access, use an array:

```d
auto c = "a|b|c|d|e".split('|');
static assert(is(typeof(c) == string[]));
// or:
auto c2 = "a|b|c|d|e".splitter('|').array; // convert range to an array
```

-Steve

Reply via email to