What is put() useful for with regards to dynamic arrays?

Andrej Mitrovic none at none.none
Fri Apr 29 21:09:09 PDT 2011


import std.range;

void main()
{
    int[] a = [1, 2, 3];
    
    a.put(6);
    assert(a == [2, 3]);
    
    a.put([1, 2]);
    assert(a.length == 0);
}

Seems kind of odd.. put is implemented as an append method for some custom types, e.g. std.array.appender. But for arrays put just removes Item or RangeLength number of elements from the array. What's the use case for this?



More information about the Digitalmars-d-learn mailing list