Changing the array upon repetition, although this is not a good idea - you may find that your code skips certain elements or does strange things. I would do
rows.reject! {|row| row.all? {|row_element| row_element.empty?}}
We reject the row if row_element.empty? block row_element.empty? evaluates to true for all elements in the row. Familiar with all the methods in Enumerable, they are very convenient for this kind of task.
source share