Variant[Variant]

Jason den Dulk public2 at jasondendulk.com
Tue Aug 27 03:53:11 PDT 2013


Hi Ali, thanks for helping me out.

On Tuesday, 27 August 2013 at 01:38:54 UTC, Ali Çehreli wrote:
> I spent 15 minutes trying to complete the code but failed. 
> Could you please provide a minimal program that almost compiles.

I uploaded a new version with a main routine. So you know, I am 
using DMD 2.063.2 on Fedora 15.

The code should compile with "dmd serialize.d".

I since realized that I was not dealing with a Variant[Variant] 
but a Variant(Variant[Variant]). It didn't seem to like having 
"[Variant]" called upon it.

After extracting it to a V[V] (called tcd1_vn), I noticed 
something else.

Doing a foreach on it,

   foreach (_a_, _b_;tcd1_vn)
   {
     writeln(_a_.type(),",",_b_.type());
     writeln(_a_.get!(string),",",_b_.get!(long));
   }

gives this:

   immutable(char)[],long
   a,1
   immutable(char)[],long
   b,2
   immutable(char)[],long
   c,3

So it appears that Variant("a") is a key, but

   assert(Variant("a") in tcd1_vn);

fails. Any ideas?

Thanks again for helping. I have been reading your online book. I 
have found it quite helpful.

Regards
Jason


More information about the Digitalmars-d-learn mailing list