Hello,

I have to make three defenitions add, subtract and calculate with has to

work with a unknown number of numbers.

So I tried this :

def add (*numbers)

numbers.inject(0) { |sum, number| sum + number }

end

def subtract(*numbers)

numbers.inject() { |sum, number| sum - number }

end

def calculate(add = true, *numbers)

if add

add.call(*numbers)

else

subtract.call(*numbers)

end

end

but then I see this errors :

defaults to addtion when no option is specified

NoMethodError

undefined method `call' for 4:Fixnum invoking calculate(4, 5, add: true) returns 9 NoMethodError undefined method`

call’ for 4:Fixnum

Can anyone give me a tip where I did go wrong ?

Roelof