Thread overview
int-double auto array
Mar 18, 2015
Dennis Ritchie
Mar 18, 2015
Adam D. Ruppe
Mar 18, 2015
Dennis Ritchie
March 18, 2015
Hi.
To create int-double array I have to pre-initialize the auto array:

import std.stdio;
import std.algorithm;

void main() {

	auto s = [5.31, 6];

	s = s.remove(0, 1);

	double k;

	readf("%s", &k); // 17.32

	s ~= k, s ~= 5, s ~= 1.125;

	writeln(s); // [17.32, 5, 1.125]
}

I can do it something like this (without initialization)?

import std.stdio;

void main() {

	auto s = []; // wrong

	double k;

	readf("%s", &k); // 17.32

	s ~= k, s ~= 5, s ~= 1.125;

	writeln(s); // [17.32, 5, 1.125]
}
March 18, 2015
On Wednesday, 18 March 2015 at 03:54:01 UTC, Dennis Ritchie wrote:
> Hi.
> To create int-double array I have to pre-initialize the auto array:

There's no such thing as an int double array, what you made there is just a double[]. The ints are converted to double when added to that array.

So you can just do

double[] s;
March 18, 2015
On Wednesday, 18 March 2015 at 04:00:04 UTC, Adam D. Ruppe wrote:
> So you can just do
>
> double[] s;

Thanks.
Yes, I overthink everything :)