Reputation: 1
def result_p3(high, low)
arr_ind = []
((1..31).each { |n| arr_ind << n })
(0..30).each do |i|
puts " #{arr_ind[i]}" + " #{'+' * high[i].to_i} ".red + "#{high[i].to_i}C "
puts " #{arr_ind[i]}" + " #{'+' * low[i].to_i} ".blue + "#{low[i].to_i}C "
end
end
Upvotes: 0
Views: 151
Reputation: 4900
arr_ind
is redundant, it contains numbers from 1 to 31 in it. For any value of x
, arr_ind[x] == x + 1
. Instead of #{arr_ind[i]}
, you could just #{i + 1}
. And of course, remove everything related to arr_ind
.
Upvotes: 0
Reputation: 84343
RuboCop is pretty clear about what the problem is: your method is too large. You can:
RuboCop is a linter and style guide. It isn't always right, but in this case it is. Your method needs to be refactored, so either do that or postpone fixing it, but definitely treat it as a code smell.
Upvotes: 1