3 Answers
3

@Jakcson'sMom tlewin's code does the same thing as yours: for each (array) element of points, assign the second value of that array to the corresponding place in points2. Except that you overshoot the end of points, and this doesn't. Perhaps that's why you're asking for help? You didn't make clear what was wrong.
–
Darshan-Josiah BarberJun 5 '13 at 20:18

I guess, if it is a Nil class error, he didn't initialized the points2 variable. The above approach, it is not necessary.
–
Thiago LewinJun 5 '13 at 20:23

1

Yeah, you fix the definite bug of indexing past the end of points and the possible bug of failing to initialize points2. And It's all-around better because it's more Ruby-like, clearer, less failure-prone, and there's no need to initialize points2.
–
Darshan-Josiah BarberJun 5 '13 at 20:25

And for the record, I up-voted your answer for all of those reasons, but your answer would be much better if you included those reasons in your answer, rather than just saying "this should be better".
–
Darshan-Josiah BarberJun 5 '13 at 20:27

@DarshanComputing You are right! When I saw your comment I realized it. Thanks!
–
Thiago LewinJun 5 '13 at 20:29