On Thursday, 22 February 2018 at 02:41:30 UTC, Steven Schveighoffer wrote:
On 2/21/18 7:30 PM, SrMordred wrote:
But with a slice negative indexes are never allowed, even on a pointer.

youd have to do
(c-1)[0 .. 1];

Nice!
Thank you both!

In D Slice article it says "You can even use negative indexes!" so I thought
that the [-1..x] should work too :)



Hah! I never thought of doing a slice with negative indexes ;)

/SNIP

-Steve

At night I dream about doing something like this

auto pos = haystack.find(needle);
auto something = haystack[pos..+3];      // meaning [pos..pos+3]
auto somethingElse = haystack[pos..-3]; // and [pos..pos-3] respectively

:)

Reply via email to