Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
array of floats for looping in Array
ages = [16, 15.6, 16.25, 17.1, 16.4, 15.8]
total_years = 0.0
ages.each do |age|
total_years += age
total_years / ages.size # => 16.191666666666666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.