Generic array

Jesse Phillips jessekphillips+d at gmail.com
Tue Nov 15 21:24:44 PST 2011


On Wed, 16 Nov 2011 00:30:44 +0100, bioinfornatics wrote:

> this works: --------------------------------------------------
> import std.string;
> import std.variant;
> import std.stdio;
> 
> void main( string[] args ){
>     Variant[] array = [ cast(Variant)1u , cast(Variant)"hi",
> cast(Variant)-2, cast(Variant)'5' ];
>     foreach( var; array ){
>         writefln( "type: %s, value: %s", var.type, var );
>     }
> }

Not testing my suggestion, but you should be able to replace all casts 
with Variant()

Variant(1u)...


More information about the Digitalmars-d-learn mailing list