Stupid question, which I think, but I searched high and low for a definitive answer to this and found nothing.
array.each_with_index |row, index|
puts index
end
Now, let's say I only want to print the first ten elements of the array.
array.each_with_index |row, index|
if (index>9)
break;
end
puts index
end
Is there a better way than this?
source
share