Inventory.opOpAssign

Adds slot(s) to the inventory (if there's enough space). Note that this function will only mutate the the inventory's slots' content without mutating its length.

  1. Slot opOpAssign(Slot slot)
    class Inventory
    @trusted
    opOpAssign
    (
    string op
    )
    if (
    op == "+"
    )
  2. Slot[] opOpAssign(Slot[] slots)
  3. uint opOpAssign(T item)
  4. uint opOpAssign(T[] items)
  5. void opOpAssign(T number)

Parameters

slot Slot

slot(s) that will be added to the inventory

Return Value

Type: Slot

the slot(s) that couldn't be added to the inventory

Examples

auto inventory = new Inventory(10);
inventory += Slot(new Items.Apple(), 32);
assert(inventory[0].item == Items.APPLE);

Meta