In this coding exercise you’ll learn how to open the Array class and add an average method that finds the average value from an array of integers.
averagemethod to Ruby’s
Arrayclass that returns the average value of the integers in the array.
Build a method that computes the average value of the elements in an Integer based array, and use monkey patching to add the method to the Array class.
Sample Method Call
[1, 2, 3].average # 2
Real World Usage
Running calculations on collections of data is a common requirement when it comes to Ruby development. Additionally, this exercise requires you to integrate monkey patching in order to add a method to a core Ruby class.
Can be found on the solutions branch on github.