Avoid subtracting form .length

Anonymouse zorael at gmail.com
Sat Nov 9 01:19:52 UTC 2024


On Friday, 8 November 2024 at 23:27:40 UTC, Dom DiSc wrote:
> I _very_ often use this pattern:
>
> ```
> fun(ref int[] a)
> {
>    assert(a.length && a.length<=100);
>    int[100] b;
>    b[0 .. a.length-1] = a[];
>    b[a.length .. 100] = 5;
> }
> ```

I use `a.length +(-1)`. It's not pretty but at least dscanner is 
happy.


More information about the Digitalmars-d-learn mailing list