From: Sangil Jung Date: 2012-08-13T18:54:08+09:00 Subject: Re: two dimensional array --047d7b3440f49bf55904c722ac70 Content-Type: text/plain; charset=UTF-8 Array#each_slice method is helpful to u. oneDarray.each_slice(3).to_a => [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 2012/8/13 ajay paswan > def get2DArray(oneDarray) #oneDarray is of dimention 1Xn^2 > ###what will be the code here?? > return twoDarray > end > > oneDarray is a one dimensional array, and is of dimention 1Xn^2, I would > like to assign this to two dimentional array namd twoDarray so that I > can get the first row as twoDarray[i]. > > for example: > oneDarray=[1,2,3,4,5,6,7,8,9] > gives > twoDarray=[[1,2,3],[4,5,6],[7,8,9]] > and twoDarray[1]=[4,5,6] > > Help me to write code at ### > > -- > Posted via http://www.ruby-forum.com/. > > -- ---------------------------------------- Sangil Jung. +82.10.6402-4639 http://humbroll.com --047d7b3440f49bf55904c722ac70 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Array#each_slice method is helpful to u.=C2=A0

oneDarray.each_slice(3).to_a=3D> [[1, 2, 3], [4, 5, 6], [7, 8, 9= ]]

2012/8/13 ajay paswan <lists@ruby-= forum.com>
def get2DArray(oneDarray) #oneDarray is of d= imention 1Xn^2
###what will be the code here??
return twoDarray
end

oneDarray is a one dimensional array, and is of dimention 1Xn^2, I would like to assign this to two dimentional array namd twoDarray so that I
can get the first row as twoDarray[i].

for example:
oneDarray=3D[1,2,3,4,5,6,7,8,9]
gives
twoDarray=3D[[1,2,3],[4,5,6],[7,8,9]]
and twoDarray[1]=3D[4,5,6]

Help me to write code at ###

--
Posted via http://= www.ruby-forum.com/.




-- ----------------------------------------
Sangil Jung.

+82.10.64= 02-4639
http://humbro= ll.com
--047d7b3440f49bf55904c722ac70--