stripRight

Array-specialization of stripRight with default predicate.

  1. inout(T)[] stripRight(inout(T)[] haystack, T needle)
  2. inout(T)[] stripRight(inout(T)[] haystack, T[] needles)
    @trusted
    inout(T)[]
    stripRight
    (
    T
    )
    (
    scope return inout(T)[] haystack
    ,
    scope const T[] needles
    )
  3. inout(char)[] stripRight(inout(char)[] haystack)
  4. bool startsWith(T[] haystack, T[] needle)
  5. bool startsWith(T[] haystack, T needle)

Examples

assert("beta".stripRight(' ') == "beta");
assert("beta ".stripRight(' ') == "beta");
assert("beta  ".stripRight(' ') == "beta");
assert("beta	".stripRight('	') == "beta");
assert("beta	".stripRight() == "beta");
assert(" _ beta _ ".stripRight(' ') == " _ beta _");
assert(" _  beta _ ".stripRight(' ') == " _  beta _");
version (unittest) {
	static char[] f()() @safe pure nothrow { char[1] x = "_"; return x[].stripRight(' '); }
	static if (hasPreviewDIP1000) static assert(!__traits(compiles, { auto _ = f(); }));
}

See Also

Meta