What is this behavior and how do I disable or get around it?

ak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Sep 4 17:43:17 PDT 2016


On Monday, 5 September 2016 at 00:26:01 UTC, pineapple wrote:
> This program does not compile.
>
> Error: cannot implicitly convert expression (cast(int)x - 
> cast(int)x) of type int to ubyte
>
>     void main(){
>         ubyte x;
>         x = x - x;
>     }
>
> I don't even know what to say. Who thought this behavior was a 
> good idea?

x = cast(ubyte)(x - x);


More information about the Digitalmars-d-learn mailing list