How to initialize an immutable array

Sparsh Mittal sparsh0mittal at gmail.com
Fri Mar 1 13:05:27 PST 2013


On Friday, 1 March 2013 at 20:28:19 UTC, FG wrote:
> I suppose this:
>
> immutable long DIM = 1024L*1024L *128L;
> immutable(double)[] signal = new double[DIM+1];
> static this() {
>     for (long i=0L; i< DIM+1; i++) {
>         signal[i] = (i+DIM)%7 + (i+DIM+1)%5;
>     }
> }
> void main()
> { ... }

Thanks. This gives an error, which I don't know how to resolve:

Error: cannot evaluate new double[](134217729LU) at compile time

Can you please tell.


More information about the Digitalmars-d-learn mailing list