shiffman / icm.shiffman.net

Site for hosting ICM videos
4 stars 3 forks source link

Shifting an array values video please #21

Open GiorgioMartini opened 10 years ago

GiorgioMartini commented 10 years ago

Hi, dan, I cant get my head around this exersice : chapter-9/example-9-8/

do the indexes get added? it cant be becuase they would go out of bounds... do they get added and then in the next iteration they go back to their original value?

please dan could you do a quick video on this ? please ... :)

thanks you so much for all your work!!!

GiorgioMartini commented 10 years ago

This is the part that i dont undertad:

// Shift array values for (int i = 0; i < xpos.length-1; i ++ ) { // Shift all elements down one spot. // xpos[0] = xpos[1], xpos[1] = xpos = [2], and so on. Stop at the second to last element. xpos[i] = xpos[i+1]; ypos[i] = ypos[i+1]; }

how come it doesnt go out of bounds? does index 1,2,3 and so on always stay in the same place but their value changes or do they actually shift?

please can you explain this quick, it wont take mre than 10 mins.. pleaseeee :)