several types in one Array ?

Paul Backus snarwin at gmail.com
Thu Oct 17 14:50:23 UTC 2019


On Thursday, 17 October 2019 at 14:45:24 UTC, Mil58 wrote:
> Hi all...
> Does exist (or not?) a way to create array with several types 
> (as in Python)
>  (example) :
>   xxx[4] myTab = [180, "John", false, -0.771];
>
> Of course, this is doing an Error ;-)   Thanks.

import std.variant;
Variant[4] myTab = variantArray(180, "John", false, -0.771);

Documentation: https://dlang.org/phobos/std_variant.html


More information about the Digitalmars-d-learn mailing list