On Fri, Jun 20, 2014 at 11:14 PM, Roelof Wobben <r.wobben / home.nl> wrote:
> I have now this ;
>
> def add (*numbers)
>   numbers.inject(0) { |sum, number| sum + number }
> end
>
> def subtract(*numbers)
>    numbers.inject() { |sum, number| sum - number }
> end
>
> def calculate(options = { :add => true,:substract => false}, *numbers)
>   add(*numbers) if options[:add] == true
>   subtract(*numbers) if options[:substract] == true
> end
>
>
> But it gives this error :
>
> defaults to addtion when no option is specified
> TypeError can't convert Symbol into Integer
> invoking calculate(4, 5, add: true) returns 9
> TypeError can't convert Symbol into Integer

Take a look at the order of the arguments when calling calculate.

Jesus.