Skip to content

Instantly share code, notes, and snippets.

@ryanckulp
Created January 1, 2018 23:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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
end
total_years / ages.size # => 16.191666666666666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment