First, please show us code that demonstrates the issue.

On 07/14/2018 07:47 AM, vino.B wrote:

>    The reason it never prints the text "Empty" is that the out of the
> "r" is just an empty array.
>
> OUTPUT:
> []
> []

If that's the output of r, then r is not empty but has two elements and those elements are likely arrays. If they are in fact arrays, them being empty does not change r: it still has two elements.

If you want to treat the range as empty when all its elements are empty, then perhaps your problem needs std.algorithm.joiner. The following program demonstrates your issue with the first assert and the fix with the second assert:

import std.algorithm;
import std.range;

void main() {
    int[][] r = [ [], [] ];
    assert(!r.empty);
    auto joined_r = r.joiner;
    assert(joined_r.empty);
}

joiner joins elements that are ranges themselves. For example, joiner([ [1], [2] ]) is equal to [ 1, 2 ].

Ali

Reply via email to