1 2 3 4
irb(main):001:0> column_1 = [1,2,3,4,5,6] => [1, 2, 3, 4, 5, 6] irb(main):003:0> column_2 = column_1.slice!((column_1.size/2.0).round..column_1.size) ...
Ruby On Split an array into half
by gudata,
August 15, 2008 12:11
1 2 3
artists = [1, 2, 3] column_1 = artists[0, (artists.size/2.0).round] column_2 = artists - column_1
1 2 3
artists = [1, 2, 3] column_1 = artists[0..artists.size/2] column_2 = artists[artists.size/2+1..artists.size]
Ruby Split an array into half
The example works if the ar...
works for any size of the a...