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

works for any size of the a...

4ee8e20a519f3afdcd03bcf24681dbd8 Talk
1
2
3
artists = [1, 2, 3]
column_1 = artists[0, (artists.size/2.0).round]
column_2 =  artists - column_1

Ruby On Split an array into half

by gudata, August 15, 2008 11:33

thanks for the (artists.siz...

4ee8e20a519f3afdcd03bcf24681dbd8 Talk
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

by gudata, August 14, 2008 09:49, 6 refactorings, tagged with ruby, array, split

The example works if the ar...

4ee8e20a519f3afdcd03bcf24681dbd8 Talk