Inventory.opOpAssign

Performs a basic math operation on every slot's count in the inventory, if not empty.

  1. Slot opOpAssign(Slot slot)
  2. Slot[] opOpAssign(Slot[] slots)
  3. uint opOpAssign(T item)
  4. uint opOpAssign(T[] items)
  5. void opOpAssign(T number)
    class Inventory
    @safe
    void
    opOpAssign
    (
    string op
    T
    )
    ()
    if (
    is(T : int) &&
    (
    op == "+" ||
    op == "-"
    ||
    op == "*"
    ||
    op == "/"
    )
    )

Examples

auto inventory = new Inventory(new Items.Apple(), Slot(new Items.Cookie(), 12));
inventory += 40;
assert(inventory == [Slot(new Items.Apple(), 64), Slot(new Items.Cookie(), 52)]);
inventory -= 52;
assert(inventory == [Slot(new Items.Apple(), 12), Slot(null)]);
inventory *= 4;
assert(inventory == [Slot(new Items.Apple(), 48), Slot(null)]);
inventory /= 24;
assert(inventory == [Slot(new Items.Apple(), 2), Slot(null)]);

Meta