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)
  2. Slot[] opOpAssign(Slot[] slots)
    class Inventory
    @safe
    opOpAssign
    (
    string op
    )
    if (
    op == "+"
    )
  3. uint opOpAssign(T item)
  4. uint opOpAssign(T[] items)
  5. void opOpAssign(T number)

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