Inbroker Adams wrote:
> Hello Rubyists,
> I am new to the language and the community.
> My first problem is this :
> 
> i used  the following code :
> 
> sum = 0
> [1,3,5].inject() {|sum, element| sum + element}
> print sum
> 
> 
> I expected to get 9
> but instead i get 4
> 
> I just installed the Ruby 1.8.6 one-click installer on windows
> and wrote the above commands in SciTE.
> Any suggestions??
>

Don't ever use inject--forget you ever read about it.   Use a hand 
written loop of your own instead.  Your code will be easier to 
understand and it will be more efficient.
-- 
Posted via http://www.ruby-forum.com/.