We can use the ~
(tilde) operator to join or concatenate two arrays.
array1 ~ array2
array1
: The first array.
array2
: The second array.
The value returned is a concatenation of array1
and array2
.
Let’s look at the code below:
// import stdioimport std.stdio;// main methodvoid main () {// an array with 5 elements.double[5] a = 5;double[5] b = [1, 2, 3, 4, 5];double [] c;c = a~b;writeln("Array c: ",c);}
std.stdio
for input and output operations. a
and b
arrays.a
and b
using the ~
operator.