On Mon, Jan 17, 2022 at 10:22:19PM +0000, forkit via Digitalmars-d-learn wrote:
[...]
> I think it's fair to say, that I'm familiar with 0-based indexing ;-)
> 
> my concern was with the 1..5 itself.
> 
> In terms of what makes sense, it actually makes more sense not to use
> it, at all ;-)

If I ever needed to foreach over 1-based indices, I'd write it this way
in order to avoid all confusion:

        foreach (i; 1 .. 5 + 1)
        {
        }

This will immediately make whoever reads the code (i.e., myself after 2
months :D) wonder, "why +1?" And the answer will become clear and
enlightenment ensues. ;-)


T

-- 
Change is inevitable, except from a vending machine.

Reply via email to