naming is important
you have a function 'sum' with a variable 'sum'
the interpreter is calling the function where you expect it to use the
variable

On Thu, Nov 20, 2014 at 8:21 AM, Roelof Wobben <r.wobben / home.nl> wrote:

>  Robert Klemme schreef op 20-11-2014 10:21:
>
> inject(0) {|s,x| s+x}
>
>
> Thanks,
>
> I tried the inject way  like this :
>
> def sum (*numbers)
>    sum.inject(0) {|sum,nummer| sum + nummer}
> end
>
> with this test :
>
> Test.assert_equals(6, sum(1,2,3) )
>
> and now I see this error : -e:3: stack level too deep (SystemStackError)
>
> Roelof
>
>