Bson.opIndex - multiple declarations
- Function Bson.opIndex
- Function Bson.opIndex
Function Bson.opIndex
Allows accessing fields of a BSON object using []
.
Returns a null value
if the specified field does not exist.
Prototype
inout inout(Bson) opIndex(
string idx
);
Example
Bson value = Bson .emptyObject;
value["a"] = 1;
value["b"] = true;
value["c"] = "foo";
assert(value["a"] == Bson(1));
assert(value["b"] == Bson(true));
assert(value["c"] == Bson("foo"));
Function Bson.opIndex
Allows index based access of a BSON array value.
Returns a null value if the index is out of bounds.
Prototype
inout inout(Bson) opIndex(
ulong idx
);
Example
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"));
Authors
Sönke Ludwig
Copyright
© 2012-2015 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.