length's type.
    kdevel 
    kdevel at vogtner.de
       
    Thu Feb  8 15:26:16 UTC 2024
    
    
  
On Thursday, 8 February 2024 at 15:00:54 UTC, Kevin Bailey wrote:
> By all means, please share with us how you would have written 
> that just as elegantly but "correct".
Elegant and correct is this version:
```d
import std.stdio;
int main()
{
         char[] something = ['a', 'b', 'c'];
         writeln("len: ", something.length);
         writeln("typeid(something.length): ",
                 typeid(something.length));
         writeln ("i: -1");
         foreach (i, _; something)
                 writeln("i: ", i);
         return 0;
}
```
But it is still a bit too "clever" in the `foreach` statement due 
to the unused variable `_`.
    
    
More information about the Digitalmars-d-learn
mailing list