What is the best way to iterate over string chars?

Cooler kulkin at hotbox.ru
Thu Feb 6 10:50:27 PST 2014


Example1:
for(size_t i; i < s.length; ++i){
   // do something with s[i]
}

Example2:
foreach(i; 0 .. s.length){
   // do something with s[i]
}

Example3:
foreach(i, c; s){
   // do something with c and i
}

What is the preferable way for portability, performance, compiler?


More information about the Digitalmars-d-learn mailing list