<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users941</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/941" rel="self"/>
  <title>gudata</title>
  <updated>Fri Aug 15 12:11:00 -0700 2008</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor15088</id>
    <published>2008-08-15T12:11:00-07:00</published>
    <title>[Ruby] On Split an array into half</title>
    <content type="html">&lt;p&gt;works for any size of the array&lt;/p&gt;

&lt;pre&gt;irb(main):001:0&amp;gt; column_1 = [1,2,3,4,5,6]
=&amp;gt; [1, 2, 3, 4, 5, 6]
irb(main):003:0&amp;gt; column_2 = column_1.slice!((column_1.size/2.0).round..column_1.size)
=&amp;gt; [4, 5, 6]
irb(main):004:0&amp;gt; column_1
=&amp;gt; [1, 2, 3]
&lt;/pre&gt;</content>
    <author>
      <name>gudata</name>
      <email>i.bardarov@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/435-split-an-array-into-half/refactors/15088" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor15086</id>
    <published>2008-08-15T11:33:47-07:00</published>
    <title>[Ruby] On Split an array into half</title>
    <content type="html">&lt;p&gt;thanks for the (artists.size / 2.0).round array and the enumeration idea&lt;/p&gt;

&lt;pre&gt;artists = [1, 2, 3]
column_1 = artists[0, (artists.size/2.0).round]
column_2 =  artists - column_1&lt;/pre&gt;</content>
    <author>
      <name>gudata</name>
      <email>i.bardarov@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/435-split-an-array-into-half/refactors/15086" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code435</id>
    <published>2008-08-14T09:49:43-07:00</published>
    <updated>2010-10-02T15:07:21-07:00</updated>
    <title>[Ruby] Split an array into half</title>
    <content type="html">&lt;p&gt;The example works if the array has more than 2 elements -  this is defect not a feature :)&lt;/p&gt;

&lt;pre&gt;    artists = [1, 2, 3]
    column_1 = artists[0..artists.size/2]
    column_2 = artists[artists.size/2+1..artists.size]&lt;/pre&gt;</content>
    <author>
      <name>gudata</name>
      <email>i.bardarov@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/435-split-an-array-into-half" rel="alternate"/>
  </entry>
</feed>

