BSON.opIndex

Allows index based access of a BSON array value.

Returns a null value if the index is out of bounds.

  1. inout(BSON) opIndex(string idx)
  2. inout(BSON) opIndex(size_t idx)
    struct BSON
    @safe inout
    inout(BSON)
    opIndex
    (
    size_t idx
    )

Examples

BSON[] entries;
entries ~= BSON(1);
entries ~= BSON(true);
entries ~= BSON("foo");

BSON value = BSON(entries);
assert(value[0] == BSON(1));
assert(value[1] == BSON(true));
assert(value[2] == BSON("foo"));

Meta