On Tue, Oct 26, 2010 at 6:11 PM, Jeremy Bopp <jeremy / bopp.net> wrote:
> On 10/26/2010 11:05 AM, Maurizio Cirilli wrote:
>> Thank you all for the very very instructive replies-
>> I have the very last question: how to make this iteration
>> through splat operator general  ®  >> in which the number of subarrays (a,b,c) in the above example
>> is unknown? I mean, the splatter operator, doing iteration
>> automatically,
>> does not return any count on the columns of the ss input m-array so
>> how to know
>> how many variables to put on the left side of the assignment
>> a, b, c = *ss 
>>
>> Maybe such question is trivial but not for me: I spent several hours
>> thinking about that and still I have no clue how to do that (the hard
>> life
>> of the beginners!!) -)
>
> It is not possible to do what you're proposing.

I go further and say: it is not even reasonable to do that.  That's
the same as setting local variables with calculated names like v1, v2,
v3 etc.  If someone wants to do that he must be aware that access to
these variables (since they are generated) must be generated as well.
In this case using an Array indexing is the more appropriate
mechanism.

>    
> iterate over the array contents, us the each method of the array object:

Exactly!

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/