From: Carlos Date: 2004-03-31T19:33:07+09:00 Subject: Re: [newbie] Array of Arrays (JRuby raise an exception) [Yvon Thoraval , 2004-03-30 10.44 CEST] > JRuby raise an exception with the following code : You should give more information if you want help: what exception, which line, etc. > > columnFields = fieldsHash.keys > columnHeaders = fieldsHash.values > selectedFields = fieldsHash.join_keys ", " > > datas = Array.new > myRows = query.executeQuery("SELECT " + selectedFields + " FROM " + tbl > + ";") > while myRows.next() > myCols = Array.new > fieldsHash.keys.each {|fhk| myCols << myRows.getString(fhk)} If fieldsHash is a normal ruby Hash, the order of the keys is arbitrary. [...] > i suspect de line : > > datas << myCols flatten the Array "datas" which has to be an Array of > Arrays that's to say each element of the Array "datas" has to be an > Array itself (being a set of columns from a database) > > the equivalent in Java/BeanShell being Vector of Vectors. > > i'm sure (print out) all datas are OK but the structure of them. > > then the question is to know if the line "datas << myCols" returns an > Array of Array or simply an concataneted Array ??? To see what is in a variable, use 'p' or #inspect. 'p' prints, #inspect returns a string. $ ruby -e 'a=["1",2,["3"]]; p a; puts a.inspect' ["1", 2, ["3"]] ["1", 2, ["3"]] Good luck.