Inventory.opIndexAssign

Sets the slot at the given index.

  1. void opIndexAssign(Slot slot, size_t index)
    class Inventory
    @safe
    void
    opIndexAssign
    (,
    size_t index
    )
  2. void opIndexAssign(Slot slot, Slice slice)
  3. void opIndexAssign(Slot[] slots, Slice slice)

Parameters

slot Slot

the item to set

index size_t

a number in range 0..$

Throws

RangeError if an invalid index is given

Examples

if(inventory[1].empty || inventory[1].item != Items.BEETROOT) {
   inventory[1] = Slot(new Items.Beetroot());
}

Meta