zero

Zeroes out the contents of an Appender.

void
zero
(
Sink : Appender!(T[])
T
)
(
ref Sink sink
,
const bool clear = true
,
T zeroValue = T.init
)

Parameters

sink Sink

The Appender to zero out.

clear bool

(Optional) Whether to also call the .clear() method of the Appender sink.

zeroValue T

(Optional) The value to zero out the contents with.

Examples

{
    Appender!(char[]) sink;
    sink.put('a');
    sink.put('b');
    sink.put('c');
    assert(sink.data == ['a', 'b', 'c']);

    sink.zero(clear: false);
    assert(sink.data == [ 255, 255, 255 ]);

    sink.put('d');
    assert(sink.data == [ 255, 255, 255, 'd' ]);

    sink.zero(clear: false, 'X');
    assert(sink.data == [ 'X', 'X', 'X', 'X' ]);

    sink.zero(clear: true);
    assert(!sink.data.length);
}
{
    Appender!(string[]) sink;
    sink.put("abc");
    sink.put("def");
    sink.put("ghi");
    assert(sink.data == [ "abc", "def", "ghi" ]);

    sink.zero(clear: false, "(empty)");
    assert(sink.data == [ "(empty)", "(empty)", "(empty)" ]);

    sink.zero(clear: false);
    assert(sink.data == [ string.init, string.init, string.init ]);

    sink.zero(clear: true);
    assert(!sink.data.length);
}

Meta