How to loop through characters of a string in D language?

forkit forkit at gmail.com
Fri Dec 10 00:32:29 UTC 2021


On Thursday, 9 December 2021 at 18:00:42 UTC, kdevel wrote:
>
> PRO:
>
> - saves two lines of boilerplate code
>
> CONS:
>
> - raw loop
> - postinc ++ is only permitted in ++C
> - inconsistent spacing around "="
> - mixing tabs and spaces for indentation
> - arrow code

more PROs:

  - You become less dependent on someone else's library.
  - You learn how to do some things yourself.

;-)

of course, I would prefer a less verbose, and safer version, 
which D enables, such as:

foreach(val; a)
     {
         writeln(val);
         if (val != ';')
         {
             b ~= val;
         }
     }




More information about the Digitalmars-d-learn mailing list