People can judge you between i++ and i+=1

  • 5
    @PublicByte And yet by writing this you wasted more time than you saved
  • 0

    void increment(int n) {
    return n+1;
  • 0
  • 3
    @CaptainRant but still... relies too much on the compiler.
    in 98% of the cases, you rather want to use ++i
  • 0
    @s0LA Would it even matter whether it's ++i or i++ if you're not assigning the value to another variable?
  • 0
    Can also be a sign of when you came up and where, kind of like how some people still religiously put the constant on the left side of comparisons bc C. For this instance, Actionscript for example had cases where i+=1 would be significantly faster after compilation, and cases where it would be slower. Just historical leftovers.
  • 0
    @s0LA Well, at my job I often do i++ without problems, though I did find some cases where i++ was a problem and I really needed ++i, indeed.
  • 0
    @CaptainRant as I mentioned; you won't have problems with because the compiler fixes it for you.
    It's in a debug build a tiny performance problem (we're talking here about 0,0x nanoseconds) but in the end, it usually is expressing something different.
  • 0
    This won't be applied for Python though.
Add Comment