Array Initialization: Difference between revisions

Content added Content deleted
(→‎Common Lisp: Migrated)
(→‎D: Looks like it's covered)
Line 104: Line 104:
std::vector v3(a, a+10); // a vector containing 10 ints, initialized with the elements of a (i.e. v3[0]==a[0] etc.)
std::vector v3(a, a+10); // a vector containing 10 ints, initialized with the elements of a (i.e. v3[0]==a[0] etc.)
std::vector v4 = v3; // v4 is a copy of v3
std::vector v4 = v3; // v4 is a copy of v3
</lang>

==[[D]]==
<lang d>
int[] y; // y is null until initialized
</lang>

<lang d>
int[3] y; // y[0] == y[1] == y[2] == int.init == 0
</lang>

<lang d>
int[] y = [1,2,3,4];
</lang>

<lang d>
int[string] y; // y is an associative array. Initially null until elements are added
y["hello"] = 3;
y["world"] = 7;
</lang>
</lang>