convert between types

Lars Johansson lasse at 11dim.se
Fri Jan 2 13:09:44 UTC 2026


     I'm writing a simple program just to get started (se below).
      mat[i][z] = z; this line generate following error:
      cannot implicitly convert expression `z` of type `ulong` to 
`char`

There are a number of ways to avoid this conversion, but I'm 
interested in best way to convert between types. How do I do this 
conversion best D practice.

Is there a cheet sheet where I can find preferably all possible 
conversions between types?
That sheet would save me hours and hours and lots of screaming in 
agony.



     import std.stdio;
     void main()
     {
         writeln("Hello, world without explicit compilations!");
         auto xmat = [
             ['a','a','a','a','a','a','a','a']
            ,['*','*','*','*','*','*','*','*']
            ,['*','*','*','*','*','*','*','*']
         ];
     initmat(xmat);
     }

     void initmat (char[][] mat) {
     import std.conv;
         foreach (i, row; mat) {
             foreach (z, tek; row) {
               //  writeln(tek);
                 mat[i][z] = z;
             }
         }
     }


More information about the Digitalmars-d-learn mailing list