skipOver

Array-specialization of skipOver with default predicate.

  1. bool skipOver(inout(T)[] haystack, T[] needle)
  2. bool skipOver(inout(T)[] haystack, T needle)
    @trusted
    bool
    skipOver
    (
    T
    )
    (
    scope ref inout(T)[] haystack
    ,
    scope const T needle
    )
  3. bool startsWith(T[] haystack, T[] needle)
  4. bool startsWith(T[] haystack, T needle)

Examples

string x = "beta version";
assert(x.skipOver("beta"));
assert(x == " version");
assert(x.skipOver(' '));
assert(x == "version");
assert(!x.skipOver("_"));
assert(x == "version");
assert(!x.skipOver('_'));
assert(x == "version");

constness of haystack and needle

{
	const(char)[] haystack;
	string needle;
	assert(haystack.skipOver(needle));
}
{
	const(char)[] haystack;
	const(char)[] needle;
	assert(haystack.skipOver(needle));
}
{
	const(char)[] haystack;
	char[] needle;
	assert(haystack.skipOver(needle));
}

See Also

Meta