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 <lists / ruby-forum.com>

> 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