Inventory.opIndex

Gets the slots in a specific range.

  1. Slot[] opIndex()
  2. Slot opIndex(size_t index)
  3. InventoryRange opIndex(Slice slice)
    class Inventory
    @safe
    opIndex
    (
    Slice slice
    )

Parameters

slice Slice

the slice obtained with opSlice, e.g. inventory[0..10]

Return Value

an <a href="#InventoryRange">InventoryRange</a> with the slots at the given indexes

Throws

RangeError if an invalid range or index is given

Examples

auto inventory = new Inventory(4);
inventory[2] = Slot(new Items.Apple(), 1);
assert(inventory[2..$] == [Slot(new Items.Apple(), 1), Slot(null)]);

Meta