在这里,我举了一个简短的例子,让你们了解你们的问题实际上在哪里。
屏幕截图1:
在第一次调用中,要么将值递减为
numberAtCounter-=1
取值范围为0到-1。因此,在第二次调用中,当函数在以下位置在线调用时:
if peopleInMatch[numberAtCounter] == yourPeerID // here you need to check value of `numberAtCounter`
确保它没有得到负值或大于peopleInMatch数组的值。
因此,如果它变为负值或大于count,结果将如下所示: