From: "Jesús Gabriel y Galán" Date: 2011-02-02T06:46:59+09:00 Subject: Re: Returning a column vector from a 2D array On Tue, Feb 1, 2011 at 8:53 PM, Jim Carter wrote: > I have a @data_array variable, which is a 2 dimensional array.  If I > run a @data_array.inspect, I get the entire 2D array in string form > reporting back to me. > > But I want to pick off a specific column, ie., create a column vector > from one of the columns on the array.  If I do something like > @data_array.length, I get an undefined method length, probably because > @data_array simply reference the Array ID??  If I do an > @data_array.inspect.length, this appears to give me the number of > elements in the complete array versus the actual length of the array. > I need to know the length, to read back a vector (I believe). > > Is there already a method existing to do this, or do I need to go down > the road of determining 2d array length, to read back a specific column > of a 2d array through a looping structure? Can you show some code? Are you using a specific 2d array from a library or are you using an array of arrays? If @data_array is referencing an object and not nil, can you show us the ouput of puts @data_array.class ? If the error you are getting mentions NilClass, you are probably not assigning anything to @data_array. Jesus.