Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shifting an array values video please #21

Open
GiorgioMartini opened this issue Feb 6, 2014 · 1 comment
Open

Shifting an array values video please #21

GiorgioMartini opened this issue Feb 6, 2014 · 1 comment

Comments

@GiorgioMartini
Copy link

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
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant