doFront

Tries to do a front but it is empty it return T.init

@safe
T
doFront
(
Range
T = ElementType!Range
)
(
Range r
,
T default_value = T.init
)
if (
isInputRange!Range
)

Return Value

Type: T

If the range is not empty the first element is return else the .init value of the range element type is return The first element is returned

Examples

{
    int[] a;
    static assert(isInputRange!(typeof(a)));
    assert(a.doFront is int.init);
}
{
    const a = [1, 2, 3];
    assert(a.doFront is a[0]);
}