I had a while loop that was something like
int i = 0
while i < 20 do
...
i+=1
end
However this is very un-ruby like. I changed this to be
20.times do |i|
...
end
which is much cleaner and easier to read. In doing this, I also realized that I had code that read:
some_integer.times.each_with_index do |i|
which is just awful. It can be rewritten with the exact same functionality as some_integer.times do |i|
. I'm not sure why I thought I needed to call #each on that, let alone #each_with_index! (If #each is redundant, #each_with_index is doubly redundant because you are already using the integer as an index, so getting the index of that index makes no sense)