Quantcast
Channel: Answers for "Array index confusion - what does [i-1] do exactly???"
Viewing all articles
Browse latest Browse all 8

Answer by RSud

$
0
0

your first time through the loop there is no value set for gearSpeeds[0] since the if statement skips setting gearSpeed[0]. I guess this is a good thing since if it didn't you first time through you would be picking up gearSpeed[-1].

So gearSpeed[0] has no value set. The coding here has a bug since you don't set any value for gearSpeed[0] but expect to use its value the second time through the loop.


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images