Variant[string] associative array ... fail?

Eljay eljay at adobe.com
Sat Apr 4 11:01:22 PDT 2009


Hi everyone,

This code works...
----------------------
import std.variant;
import std.stdio;
void main()
{
  Variant v;
  v = "hello";
  writeln(v);
}
----------------------

But this code does not...
----------------------
import std.variant;
import std.stdio;
void main()
{
  Variant[string] v;
  v["there"] = "hello";
  writeln(v["there"]);
}
----------------------
...resulting in this runtime failure:
core.exception.RangeError at Var(6): Range violation

What did I do wrong?

Using Digital Mars D Compiler v2.027, on OS X 10.5.6.

Thanks,
--Eljay





More information about the Digitalmars-d mailing list