Vector.opOpAssign

Assign result of applying operator with scalar to elements.

  1. Vector opOpAssign(T scalar)
    struct Vector(T, uint N)
    pure ref return
    opOpAssign
    (
    string op
    )
    (
    const T scalar
    )
    if (
    !op.among("~", "<<", ">>", ">>>")
    )
    if (
    N > 0
    )
  2. Vector opOpAssign(T[M] other)

Examples

Vec2i v = [1, 2];
v += 5;
assert(v == [6, 7]);
v -= 4;
assert(v == [2, 3]);
v *= -1;
assert(v == [-2, -3]);
v %= 3;
assert(v == [-2, 0]);
v |= 1;
assert(v == [-1, 1]);
v /= 2;
assert(v == [0, 0]); // integer division

Meta