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

ios - iPhone/iPad different view orientations in different views , and apple approval process -

monitor web browser programmatically in Android? -

c# - Using multiple datasets in RDLC -