Java wildcards... in D

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 18 14:17:18 PST 2016


On 01/18/2016 02:08 PM, Voitech wrote:

 > alias Element =Algebraic!(real,string);
 >
 > i will get:
 >
 > Cannot store a int in a VariantN!(16LU, real, string)

Are you really storing a 'real' or a 'string'? (The default floating 
type in D is double, not real.) The following compiles and works as 
expected with dmd v2.069.2:

import std.variant;

void main() {
     alias Element =Algebraic!(real,string);
     auto r = Element(1.2L);
     auto s = Element("hello");
}

Ali



More information about the Digitalmars-d-learn mailing list