From: "Peña, Botp" Date: 2006-08-07T18:26:03+09:00 Subject: Re: inject does not inject last value fr Ryan: [snipped cool samples] # Because sum was assigned initially outside of the inject, it is an # lvar (local variable) instead of a dvar (dynamic/iter var, like e). # You'll notice that the assignments to both of those variables # happens # before the call, and is part of the iteration mechanics # itself. There # is no assignment done at the end of an iteration. # # I think it is more important to point out that inject is # _just_another_iterator_. There is nothing special about it or how it # works. It is just a simple each just like everything else in # Enumerable. This makes the ruby implementation cleaner and easier to # maintain. Sum isn't an accumulator, as much as it is just another # variable. Should map or reject have some special semantics attached # to their block variables? # # If you really are stuck on this idea, you can always change "sum+e" # to read "sum+=e" but at that stage, why use an inject at all? [snipped code explanation] Hi Ryan, thank you for the very detailed and enlightening explanation. I apologize for being too dumb on this inject stuff (). kind regards -botp