To find the average of a list of numbers in ruby, you can use the built-in reduce method and divide the sum by the length of the array:
main.rb111 chars4 linesThe reduce method adds up all the elements in the array by calling the + method on each element. The to_f method converts the length to a float, so that the result of the division will be a float.
gistlibby LogSnag