From: jzakiya Date: 2010-12-28T03:00:16+09:00 Subject: Re: inject issue On Dec 27, 12:46 pm, w_a_x_man wrote: > On Dec 27, 2:10 am, jzakiya wrote: > > > > > > > > > > > When I do this: > > > %w/ap mathn roots facets/.inject :require > > > whatever is the first item in the list doesn't get loaded by 'require' > > > When I do this: > > > %w/ap mathn roots facets/.inject 0, :require or .inject(0, :require) > > > then the first item is also loaded.  (the '0' can be essentially > > anything) > > > Is this a bug, or is this the expected operation? > > > This behavior is consistent across 1.8.7, 1.9.1/2 and jruby using RVM. > > It's clearer to use fences. > > %w(ap mathn roots facets).each{|s| require s} Why question is on the operation of 'inject'. Are these different: %w/lib1 lib2 lib3/.inject :require %w/lib1 lib2 lib3/.inject 0, :require because 'require' operates on one item at a time whereas these are equivalent: (1..100).inject :+ (1..100).inject 0, :+ because '+' operates on two items at a time? Again, my focus in why 'inject' behaves differently under these two examples.