On 01/12/11 11:07, Sbastien M. wrote:
> Thx for ur response Sam
> For the first issue indeed (newbie to ruby ;)
>
> For the second happy there is a fix.
> But i don't understand.
> For what i've read inject combines all element of an array by applying a
> method or block on each
> How come inject uses the Numeric#+ instead of my Item#+ since all
> elements are items???????
> That puzzled me
>
> Does someone understands that? It don't make sens to me
>
I won't pretend to know what is happening under the hood, but my simple 
minded assumption is that inside the inject, the method is being called 
iteratively with a temp var holding the result.

If you were to do item1+item2, the result would be a Numeric object. If 
you then did result+item3, you are suddenly calling Numeric#+ rather 
than Item#+ (because result is the receiver)

I'm sure someone else will be able to clarify this for you and point out 
if my assumption is horribly wrong/ misguided.

Sam