You can use the slice operator "[" to assign one value to multiple values inside an array:
int[3] foo;
bar[] = 2;
foo[] = 5;
bar[0..2] = 2;
|
This is the same as writing:
foo[0] = 5;
foo[1] = 5;
foo[2] = 5;
|
But D goes one step further. The following two examples do the same:
for (int i=0; i<2; i++)
{
bar[i] = foo[i] +5;
}
|
See also:
Array Copying,
Array Slicing
|