Data structures of mixed type
Andrea Fontana via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 8 02:02:25 PDT 2016
On Thursday, 8 September 2016 at 08:56:13 UTC, Russel Winder
wrote:
> What is the idiomatic way of having an array with a mix of int
> and float data?
Maybe https://dlang.org/phobos/std_variant.html#.Algebraic ?
> Is relying on automated conversion of int to float acceptable?
I don't think so:
import std.stdio;
void main()
{
int i = 12345678;
float f = i;
writeln(f);
}
Andrea
More information about the Digitalmars-d-learn
mailing list