digitalmars.D.learn - int-double auto array
- Dennis Ritchie (22/22) Mar 17 2015 Hi.
- Adam D. Ruppe (6/9) Mar 17 2015 There's no such thing as an int double array, what you made there
- Dennis Ritchie (3/5) Mar 17 2015 Thanks.
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]
}
Mar 17 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;
Mar 17 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 :)
Mar 17 2015








"Dennis Ritchie" <dennis.ritchie mail.ru>