<br><br><div class="gmail_quote">On Thu, Feb 11, 2010 at 21:22, GG <span dir="ltr"><<a href="mailto:g@g.com">g@g.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
I tried your trick but I got "Error: cannot append type string to type VariantN!(maxSize)[]"<br>
on : vars ~= "Jan";<br>
<br>
I found this : <a href="http://d.puremagic.com/issues/show_bug.cgi?id=3692" target="_blank">http://d.puremagic.com/issues/show_bug.cgi?id=3692</a>, the issue has been REOPEN.<br>
<br>
Thanks for helping !<br></blockquote><div><br>Hmm, it worked for me, but that was almost a year ago. Maybe I wrapped a Variant around?<br><br>vars ~= Variant("Jan");<br> <br></div></div>(*testing*)<br><br>Yes, it works:<br>
<br>Variant[] vars;<br>int[char[]][int] indices;<br><br>vars ~= Variant("Jan");<br>indices[0]["Month"] = vars.length-1;<br><br>Ugly as sin, though, and cumbersome to use. But I used it to add 'properties' to nodes and edges in a graph class (like, adding weight to edges as double, and names to nodes as strings...) and it worked quite well, with a few functions to hide the trick away.<br>
<br>But it's sad you can't use Variant directly as a value. You can use it as a key, sort of:<br><br>int[Variant] test;<br>test[Variant(3)] = 4; // test[3] = 4 does not work<br>test[Variant("abc")] = 0;<br>
writeln(test[Variant("abc")]); // 0<br>auto k = test.keys; // crash! Assertion failure: 'impl' on line 3886 in file 'mtype.c'<br><br>