0
column = column >= (numberOfColumns - 1) ? 0 : ++column

I am trying to increment my column variable through a ++ sign but it's now deprecated. What is the perfect sign for this increment?

I have tried both column++ and column += 1. Though it works under a normal if-else condition, I want to implement this through an inline condition.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Adhri
  • 1
  • Related, and one of the answer probably addresses this: https://stackoverflow.com/q/35158422/1531971 –  Sep 22 '17 at 18:56
  • 1
    Your code would be much clearer if you simply used `column = (column + 1) % numberOfColumns`. It's easier to write and the intent is clearer to most programmers. – rmaddy Sep 22 '17 at 19:04

1 Answers1

0

What about a simple incrementation?

column = column >= (numberOfColumns - 1) ? 0 : column + 1
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223