When using the .length property of a dynamic array why does it
return the incorrect number of elements after I use the appender?
import std.stdio;
import std.array : appender;
void main()
{
//declaring a dynamic array
int [] arrayofNumbers;
//append an element using the ~= syntax
arrayofNumbers ~= 1;
arrayofNumbers ~= 2;
//print the array
writeln(arrayofNumbers);
//Using appender
auto appendNumber = appender(arrayofNumbers);
appendNumber.put(10);
writeln(appendNumber.data);
writeln(arrayofNumbers.length);
}
Output:
[1, 2]
[1, 2, 10]
2 --- > Should be 3