On Friday, 26 May 2023 at 13:18:15 UTC, Steven Schveighoffer wrote:

This worked for me:

```d
char[4] fourC(string s)
{
    if(s.length >= 4)
        return s[0 .. 4];
    char[4] res = 0;
    res[0 .. s.length] = s;
    return res;
}
```
Sometimes I forget that the return does an implicit cast. And it looks inside the slice [..] if it constant or not. Lot of things going on under the hood...

Thank You!

Reply via email to