Macaulay2 » Documentation
Packages » Macaulay2Doc » The Macaulay2 language » variables » augmented assignment
next | previous | forward | backward | up | index | toc

# augmented assignment

Most binary operators have an associated augmented assignment operator that modifies the given object using the corresponding binary operator. Essentially, `x OP= y` is equivalent to `x = x OP y`.

    i1 : x = 2

    o1 = 2

    i2 : x += 3

    o2 = 5

    i3 : x -= 4

    o3 = 1

    i4 : x *= 5

    o4 = 5

    i5 : x /= 6

         5
    o5 = -
         6

    o5 : QQ

The following augmented assignment operators are supported.

    i6 : importFrom(Core, "augmentedAssignmentOperators");

    i7 : augmentedAssignmentOperators

    o7 = (<<=, >>=, ||=, <==>=, |-=, ??=, ==>=, ===>=, |=, ^^=, &=, ..=, ..<=,
         ------------------------------------------------------------------------
         -=, +=, ++=, **=, *=, \\=, /=, \=, %=, //=, @=, @@=, @@?=, |_=, ^=, _=,
         ------------------------------------------------------------------------
         ^**=, ·=, ⊠=, ⧢=)

    o7 : Sequence

## See also

- installing augmented assignment methods

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Macaulay2Doc/operators/augmented_assignment.m2:24:0.