Kenosis
6/12/2006 8:43:00 PM
Thanks Robert - that's what I thought too but my test in irb failed.
Must be that I have to use *array when passing it to GetopLong.
Regards,
Ken
Robert Klemme wrote:
> Kenosis wrote:
> > Greetings Rubyologists,
> >
> > Suppose we have a simple array of arrays, e.g., [[1], [2], [3]]. What
> > would be the cleanest way, if it's possible, to remove the outter level
> > of array nesting such that the result is (a) a list of arrays: [1],
> > [2], [3], and (b) suitable for passing as a list of arrays to
> > GetoptLong. Thanks in advance for any help you can lend.
>
> Your array *is* already a "list" of arrays. Maybe you just need the
> star operator. Consider
>
> irb(main):001:0> def foo(*args) p args end
> => nil
> irb(main):002:0> foo([[1],[2]])
> [[[1], [2]]]
> => nil
> irb(main):003:0> foo(*[[1],[2]])
> [[1], [2]]
> => nil
>
> Kind regards
>
> robert