Sha256: 1601f9fcaa175bbef74170f2791fad21fdbafcfefe9846b4ca861965ad0711ac
Contents?: true
Size: 340 Bytes
Versions: 1
Compression:
Stored size: 340 Bytes
Contents
# encoding: utf-8 # Array class Array # return average # # === Example # # [*1..6].average # => 3.5 # [1.5, 2.5].average # => 2.0 # [*'a'..'z'].average # => raise TypeError # def average fail TypeError, 'you have to use elements that is Numeric' unless all? { |v|v.is_a? Numeric } sum.to_f / size end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tbpgr_utils-0.0.151 | lib/open_classes/array/average.rb |