From: sto.mar@... Date: 2012-10-03T04:34:52+09:00 Subject: Re: how to read arrary with an array Am 02.10.2012 20:44, schrieb Richard D.: > array1.each do |ray| #four outputs of a, b1, 2x, y > puts ray[0] > puts '****' > puts ray[1] > end > > I was assuming I would get the same outcome. Well, that's wrong. You did not understand how Array#each works. Each array element is passed to the variable `ray` and then the **complete** block is evaluated for that single element, then the next element is passed to ray etc. Array#each does *not* evaluate each line for all array elements and then go to the next line. > It should be noted, I'm not far enough in the book to have blocks > explained, so are this point, in how it used, it's more a way to turn a > method output into a variable, with will do something later. No, you misunderstood what the author is saying. But at the moment you do not have to understand more about blocks than that they here behave similar to the block of a while loop. Array#each is explained *in detail* in chapter 8.1, please reread. > On a side note, I have not a clue of what slice is or what it does or > does not do. I just wanted to point out that an array that contains an array is not a 2x2 matrix with rows and columns, and also can contain objects that do not even have an element reference (so that object[3] is not possible and gives a syntax error). --