On Friday, 2 January 2026 at 13:09:44 UTC, Lars Johansson wrote:
    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;
            }
        }
    }

I found a solution wchar  cast(wchar) (z + '0');
first declare the array as wchar
then add '0' to the value
then cast(wchar) (z + '0')

I do not find this very easy to figure out. I found the conversion chapter in the manual from there I saw wchar is more likely to work. the add zero claude helped me with.
A cheet sheet would be very nice to have.

From this I learned to hex display everything that I have conversion problem with.

Reply via email to