Regarding std.array.Appender
Ali Çehreli
acehreli at yahoo.com
Wed Feb 29 21:21:12 PST 2012
On 02/29/2012 08:28 PM, James Miller wrote:
> I understand that Appenders aren't arrays, and should not be used as
> such, but you /can/ use an array as an Appender.
Yes you can but whatever you put() into the array is immediately
popFront()'ed from the array. ;) You must use a temporary surrogate slice:
import std.stdio;
import std.range;
void main()
{
int[] array = [ 1, 2, 3 ];
int[] slice = array;
put(slice, 100); // <-- slice shrinks! :)
}
slice.length is 2 and array.length is 3.
> At some point, you
> have to concede design purity to convenience, otherwise you have a
> language that is actively hostile to changing designs.
Agreed.
Ali
More information about the Digitalmars-d-learn
mailing list