class Array

Public Instance Methods

average() click to toggle source
# File lib/expressive_math/array.rb, line 11
def average
  self.inject { |total, number| total + number }.to_f
end
total() click to toggle source
# File lib/expressive_math/array.rb, line 2
def total
  if self.length > 0
    return self[0] if self.length == 1
    self.inject(0) { |number, total| total + number }
  else
    0
  end
end