Ran across some old code today, in which a minus-sign "-" is added in front of a function that returns a number...

Ran across some old code today, in which a minus-sign "-" is added in front of a function that returns a number... 

MyObj.ChangeValue( - MiscFuncToGetANumber() );

I guess I would normally write this as...

MyObj.ChangeValue(MiscFuncToGetANumber() * -1);

Do you use a minus sign "-" like this?

I think it's super weird looking.

Comments

  1. Vin Colgin Sadly no. Some feel they don't belong in a Pascal-based language, but I constantly miss them...

    ReplyDelete
  2. Asbjørn Heid Interesting. The first thing I thought when I saw the "unary minus" was that it was the same as a "compound assignment operand" and that Delphi had my beloved IntVal++ there all the time and didn't know it. Oh well. Gunna have to play with the "unary minus" more, my mind has a hard time seeing a "-" in front of a function.

    ReplyDelete
  3. Vin Colgin You've probably used the "not" operator which is the "equivalent" for logic expressions.

    ReplyDelete

Post a Comment