I’m trying to subdivide an array into pairs of arrays.
For example: ["A","B","C","D"] should become [["A","B"],["C","D"].
I believe I’ve succeeded by doing arg.each_slice(2).to_a.
But if I were then to do arg.length on the new array I still get 4.
I expect to get 2 (in the above example).
In the end, I want to be able to call the first element of arg to be ["A","B"] but at the moment, I am still getting "A".
Maybe you are expecting that
array.each_slice(2).to_awill change your originalarray, but here you will have newArrayobject, becauseeach_sliceis non-destructive method, like most in ruby.