On Friday, 14 May 2021 at 14:14:03 UTC, Steven Schveighoffer wrote:
On 5/13/21 11:49 PM, Jack wrote:
[...]

Just slice the `a`, appropriately. You have to translate the indexes back into the original array.

```d
auto opSlice(size_t start, size_t end)
{
  return typeof(this)(a[$ - end .. $ - start]);
}
```

You should also define `length`, `save`, `opIndex`, and `opDollar` so that it fits in the range hierarchy as a proper random-access range.

But I question whether you shouldn't just use `std.range.retro` directly? It does all this for you:

```d
// inside A
auto retro() {
   import std.range : retro;
   return arr.retro;
}
```

-Steve

much easier, I'll be just using the one from std.range. Thanks!

Reply via email to