On Saturday, 12 February 2022 at 12:36:06 UTC, BoQsc wrote:
`bool nextArgumentDoesNotReachEndOfArray = i + 1 < args.length;`

How can I declare it out of scope and reuse it in any scope that has `i` and `args.length` declared?

Here is an ugly solution, just to encourage someone else to post better:

```d
enum n = "i+1<args.length";

void main()
{
    int i;
    string[] args;
    assert(!mixin(n));
    args.length += 2;
    assert(mixin(n));
    testOtherScope();
}

void testOtherScope()
{
    int i;
    string[] args;
    assert(!mixin(n));
    args.length += 2;
    assert(mixin(n));
}
```

The problem with that solution is that it's not clean.
The problem of the initial problem is to have automatic capture of `i` and `args` in any scope...

Lost cause ?

Reply via email to