Interesting user mistake
Mint via Digitalmars-d
digitalmars-d at puremagic.com
Thu Sep 3 12:07:03 PDT 2015
On Thursday, 3 September 2015 at 18:31:59 UTC, Meta wrote:
>
> Worse than useless; it doesn't even behave as you would expect.
>
> import std.stdio;
>
> void main()
> {
> auto a = -1;
> writeln(+a); //Prints -1
> writeln(-a); //Prints 1
> }
>
> At least unary - does something.
I mean, if behaves exactly as I'd expect. +(-1) must equal -1, as
-(-1) produces +1.
Also, recall that you can overload the unary + operator, so it
may behave differently for some aggregate types.
More information about the Digitalmars-d
mailing list