Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
Appender!(E) appender(A, E)
( auto ref Aarray );
auto w = appender!string;
// pre-allocate space for at least 10 elements (this avoids costly reallocations)
assert(w.capacity >= 10);
w.put('a'); // single elements
w.put("bc"); // multiple elements
// use the append syntax
w ~= 'd';
w ~= "ef";
writeln(w); // "abcdef"
Implements an output range that appends data to an array. This is
recommended over array~= data when appending many elements because it is more
efficient. Appender maintains its own array metadata locally, so it can avoid
global locking for each append where capacity is non-zero.
Constructs an Appender with a given array. Note that this does not copy the
data. If the array has a larger capacity as determined by arr.capacity,
it will be used by the appender. After initializing an appender on an array,
appending to the original array will reallocate.