P
Pen Ttt
class Mycompute
def self.sum(a)
a.inject(0){|s,i|s+i}
end
def self.mean(a)
a.inject(0){|s,i|s+i}/(a.size.to_f)
end
end
Mycompute.sum([1,2,3,4])
=> 10
Mycompute.mean([1,2,3,4])
=> 2.5
how can i get Mycompute.sum([1,2,3,4]).mean=2.5?
def self.sum(a)
a.inject(0){|s,i|s+i}
end
def self.mean(a)
a.inject(0){|s,i|s+i}/(a.size.to_f)
end
end
Mycompute.sum([1,2,3,4])
=> 10
Mycompute.mean([1,2,3,4])
=> 2.5
how can i get Mycompute.sum([1,2,3,4]).mean=2.5?