On Friday, 25 October 2019 at 06:59:07 UTC, Per Nordlöw wrote:
/** Array-overload for `skipOver` with no explicit predicate predicate. */
bool skipOver(T)(scope ref const(T)[] haystack,
                 scope const(T)[] needle)

Found it.

The parameter `haystack` must be qualified with inout instead of const because it's `ref`.

bool skipOver(T)(scope ref inout(T)[] haystack,
                 scope const(T)[] needle)
{
    if (startsWith(haystack, needle))
    {
        haystack = haystack[needle.length .. $];
        return true;
    }
    return false;
}

Why?

Reply via email to