I am starting to learn ruby and am trying to figure out a way to if i have an array of 16 numbers, to print those numbers 4 at a time using only the each method. I can easily do this with a loop but i am lacking full understanding of the each method in Ruby so this gives me some trouble.
I have the following:
x=[*1..16]
index=0
x.each do |element|
puts element[index]
index=index+3
end
Now obviously this is completely wrong and i know that but i wanted to put something on here. A little advice would be great.
Thank you
A possible solution:
EDIT: If you want print 4 elements on one line, then skip to the next line and print the next 4 elements, etc
Or using each only