答案 0 :(得分:4)
它应该是currentAudioIndex++
(没有空格)。它与:currentAudioIndex = (currentAudioIndex)%2
currentAudioIndex = (currentAudioIndex++)%2
// plus 1 to currentAudioIndex will be overrided by `currentAudioIndex =`.
// With (currentAudioIndex++)%2. E.g currentAudioIndex = 1
// 1. currentAudioIndex return 1 for the operator %. It's "1%2"
// 2. currentAudioIndex plus 1. currentAudioIndex == 2 now.
// 3. The operator % (1%2) return 1 for currentAudioIndex.
// 4. currentAudioIndex == 1 at the end.
但在你的情况下,我认为你想要这个++currentAudioIndex
。它与
currentAudioIndex = currentAudioIndex + 1
currentAudioIndex = (currentAudioIndex)%2
答案 1 :(得分:1)
currentAudioIndex ++在计算表达式后递增值。 在计算表达式之前,可以尝试使用++ currentAudioIndex递增。