I've got the following array:
a = ['sda', 'sdb', 'sdc', 'sdd']
Now I want to loop through these entries but always with two elements. I do this like the following at the moment:
while b = a.shift(2)
# b is now ['sda', 'sdb'] or ['sdc', 'sdd']
end
This feels somehow wrong, is there a better way to do this? Is there a way to get easily to something like [['sda', 'sdb'], ['sdc', 'sdd']] ?
I read http://www.ruby-doc.org/core-1.9.3/Array.html but I didn't find something useful...