Array Template

codephantom me at noyb.com
Mon Dec 18 11:31:02 UTC 2017


On Saturday, 16 December 2017 at 14:14:28 UTC, Vino wrote:
>
> Yes, will give a try.
>
> From,
> Vino.B


well, this sort of gets there ;-)

// -----
module test;

import std.stdio;
import std.variant;
import std.typecons;
import std.conv;
import std.string;

void main()
{
     Variant[] arr;

     auto x = tuple(5, "hello", 4.3);
     arr ~= cast(Variant)x;

     auto y = tuple("hello", 4.3);
     arr ~= cast(Variant)y;

     auto z = tuple("hello", "world", 1, 2, 3, 5.5);
     arr ~= cast(Variant)z;

     int i = 0;
     foreach(elem; arr)
     {
         writeln(
                 "arr[", i, "] values are : ",
                 to!(string)((to!(string)(elem))
                 [( indexOf( to!(string)(elem), ")" ) + 
2)..($-1)]) );
         i++;
     }

}
// -----


More information about the Digitalmars-d-learn mailing list