On Sat, Apr 19, 2003 at 02:16:49AM +0900, Andi Scharfstein wrote:
> I have implemented the multi-dimensional array as stated on
> http://www.ir.isas.ac.jp/~masa/ruby/mdary.html, like so:
> 
> class MDArray < Array
>         def [](n)
>                 self[n] = MDArray.new if super(n) == nil
>                 super(n)
>         end
> end
> 
> Now I wonder: is there a more efficient way to keep track of rows and
> columns of this array, i.e., is there some method to extract the
> number of rows a particular column has, and vice versa? Thanks a lot.

Have you tried:

   foo.size     # number of subarrays
   foo[0].size  # number of elements in this subarray