On 7/25/07, Erik Boling <schmode93 / yahoo.com> wrote:
> Oh Thanks so much, but i dont have the irb main in C:? and its not in my
> ruby folder.. so im DL'ing again. I was wondering can somoe one explian
> the 3rd, 4th and 5th lines on gavins response

irb.bat (along with your other ruby-related executables) should be in
the bin directory inside your ruby directory.  For example, mine is
c:\ruby\bin\irb.  After you find where it is, you should set your
environment PATH variable if it isn't set correctly already.
Right-click on My Computer, select Properties.  Select Advanced tab,
Environment Variables button.  Under System Variables, look for your
ruby\bin directory for Path.  If it isn't there or is wrong, add it to
the end with a preceding semicolon (;).

third expression: think of the zip function as stacking your arrays,
one atop the other, and making arrays out of the vertical columns; you
now have a main array with arrays (the columns) as its elements

fourth expression: the map function takes each element of an
Enumerable object (of which Array is one type) and does something with
it; in this case, adding the two parts of the element

fifth expression: he extends the behavior of an Enumerable object with
a new method called sum using an existing method inject; inject is an
accumulator function, going through each element and whatever is
evaluated gets injected back into the first parameter (in this case,
s) for the next iteration

The fifth one would be confusing to people new to programming, but its
there so that you can sum over more than just two arrays (which is
what he he was doing in the fourth expression).  It is a common way to
sum in Ruby.

You can read about how zip, map, and inject work at http://www.ruby-doc.org/core

hth,
Todd