Value.opIndex

Get value by key

  1. inout(Value) opIndex(in string key)
    struct Value
    @safe ref
    inout(Value)
    opIndex
    inout pure
    (
    in string key
    )
  2. inout(Value) opIndex(in Value key)

Examples

1 Value v1 = cast(Value[Value]) null;
2 const string abc = "abc";
3 const Value  def = Value("def");
4 
5 v1["abc"] = true;
6 v1[def] = 3.14;
7 v1[Value("xyz")] = Value("foo");
8 
9 
10 assert(v1["abc"] == true);
11 assert(v1["def"] == 3.14);
12 assert(v1["xyz"] == "foo");
13 
14 // const
15 const Value  v2  = v1;
16 
17 assert(v2[abc] == true);
18 assert(v2[def] == 3.14);
19 assert(v2[Value("xyz")] == "foo");

Meta