whenEmpty

Undocumented in source. Be warned that the author may not have intended to support it.
  1. auto whenEmpty(R range)
  2. auto whenEmpty(R range, Fn fn)
    whenEmpty
    (
    R
    Fn
    )
    (,
    Fn fn
    )
    if (
    isCallable!Fn
    )

Examples

{
    auto arr = [1, 2, 3];
    auto r = arr.whenEmpty((){ arr = null; });
    assert(equal(r, arr));
    assert(arr is null);
}
{
    auto arr = [1, 2, 3];
    auto r = arr.whenEmpty((){ arr = null; });
    //assert(equal(r, arr));
    r.popFront(); r.popFront();
    assert(arr !is null);
    r.popFront();
    assert(arr is null);
}

Meta