On Sunday, 25 February 2018 at 05:40:19 UTC, Jonathan M Davis wrote:

    int[] intArr = iota(1, 11).array();


- Jonathan M Davis

thanks!

oh man.  It's so easy to do stuff in D ;-)

But this leads me to a new problem now.

When I run my code below, I get ints printed instead of doubles??

---------------------
module test;

import std.stdio : writeln;
import std.traits : isArray;
import std.array : array;
import std.range : iota;


void main()
{
    int[] intArr = iota(1, 11).array(); // 1..10
    double[] doubleArr = iota(1.0, 11.0).array(); // 1.0..10.0
    char[] charArr = iota('a', '{').array();  // a..z

    printArray(intArr);
printArray(doubleArr); // why is it printing ints instead of doubles??
    printArray(charArr);
}

void printArray(T)(const ref T[] a) if (isArray!(T[]))
{
    foreach(t; a)
        writeln(t);
}

---------------------------------

Reply via email to