Using the Modulus operator to wrap around in Reverse order

后端 未结 0 855
忘了有多久
忘了有多久 2021-01-30 01:36

I normally use modulus when I want to wrap around a number i.e.

current = (current + 1) % list.size()

In a loop this would go from 0,1,...,list

相关标签:
回答
  • 消灭零回复
提交回复
热议问题