I guess that because in the second one c is a mutable object that is
updated while in the first one is an inmutable one ovewriten.
El jun 12, 2014 8:34 a.m., "gvim" <gvimrc / gmail.com> escribi:

> Why do these accumulators behave differently?
>
> def int_outer(a,b)
>   c = 0
>   def inner(aa,bb,cc)
>     cc += (aa + bb)
>   end
>   inner a, b, c
>   inner b, a, c
>   return c
> end
>
> p int_outer 3,4   #=> 0
>
> def arr_outer(a,b)
>   c = []
>   def inner(aa,bb,cc)
>     cc << (aa + bb)
>   end
>   inner a, b, c
>   inner b, a, c
>   return c
> end
>
> p arr_outer 3,4  #=> [7,7]
>
>
>
> gvim
>