How does array assignment for different sized types work?

FG home at fgda.pl
Thu Jan 31 03:11:22 PST 2013


On 2013-01-31 10:47, Timon Gehr wrote:
> The reason is that array literals have special conversion rules

It's because floating point literals are double by default.
In the first assignment float type can be deduced from v1.
To make the second one work, you can explicitly make them float:

     float[3] v1 = [1.0, 2.0, 3.0];
     float[3] v = [1.0f, 2.0f, 3.0f].dup;

or duplicate v1:    float[3] v = v1.dup;


More information about the Digitalmars-d-learn mailing list