why does this compile fine, but dies when you run it.
steven kladitis
stevenkladitis at gmail.com
Thu Mar 22 14:05:02 UTC 2018
On Wednesday, 21 March 2018 at 18:55:34 UTC, Adam D. Ruppe wrote:
> On Wednesday, 21 March 2018 at 18:53:39 UTC, steven kladitis
> wrote:
>> int[] array3;
>> array3[0]=4;
>
> array3 is empty. You are trying to set a value that doesn't
> exist..
import std.stdio;
void main(){
int[3] array1 = [ 10, 20, 30 ];
auto array2 = array1; // array2's elements are different
// from array1's
array2[0] = 11;
int[] array3;
//array4[0]=3;
array3 ~=4;
auto array4 = array3;
array4 ~=2;
int[string] a1;
int[int] a2;
a1["V"]=2;
a2[4]=3;
writeln(array1,'\n',array2,'\n',array3,'\n',array4,'\n',a1,'\n',a2);
}
-- this works, why??
-- what is the difference between int[] x; and int[int] x; ????
-- thanks
-- Steven
More information about the Digitalmars-d-learn
mailing list