digitalmars.D.learn - Iterating over a variant conaining an associative array
- "Juanjo =?UTF-8?B?w4FsdmFyZXoi?= <juanjux gmail.com> (15/15) Aug 23 2012 This works:
This works: string[] l = ["one", "two", "three"]; auto vl = Variant(vl); foreach(Variant i; vlist) writeln(i); (Note how I don't need the contained type for iterating over it). This doesn't work: string[int] d = [1: "one", 2: "two", 3: "three)]; auto vd = Variant(d); foreach(Variant i; vd) writeln(i); This gives the error: std.variant.VariantException std\variant.d(1209): Variant: attempting to use incompatible types uint and immutable(char)[] Getting the elements with the opIndex (like vd[1]) works. Is there any other way to iterate over vd elements without knowing the exact type and retrieving it with get!TYPE?
Aug 23 2012