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

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -