From: "Jesús Gabriel y Galán" Date: 2010-07-28T22:11:55+09:00 Subject: Re: multidimensional array insert syntax On Wed, Jul 28, 2010 at 2:26 PM, Dave Castellano wrote: > Jesús Gabriel y Galán wrote: >> On Wed, Jul 28, 2010 at 1:10 PM, Robert Klemme >> wrote: >> >>> Use Array#insert. >> >> Amazing how I missed that, given that I was specifically looking for >> it in the rdoc :D >> I call "sleep deprived", or something >> >> Jesus. > > That works for single dimension arrays but I can't figure out the syntax > for multi... > > I have been trying to use "answer_choices.insert" but cannot figure out > the syntax > eg answer_choices.insert([x][1],correct_ans_1) does not work.. > > Could you give me an example of Array#insert. using multidim. array In order to better understand it, I'm afraid you will need to stop thinking about multidimensional arrays, and start thinking of arrays of arrays. First you need to get the inner array: answer_choices[x] then you get back an array. It's on this inner array where you want to insert, so (split in two steps): inner = answer_choices[x] inner.insert(0, correct_ans_1) Jesus.