Rails Average - Discount 0 values -
i create arrays need find averages of follows:
total_rating = [] #add numbers total_rating average = total_rating.inject(:+).to_f / total_rating.size
how can remove values of 0 average calculation? dont want 0 row computed in average calculation.
total_rating.reject(&:zero?)
Comments
Post a Comment