On Feb 1, 9:57 pm, "Bill Kelly" <b... / cts.com> wrote:
> From: "Chris Shea" <cms... / gmail.com>
>
>
>
> > Tested, and failed. The index returns the position of the very first
> > space. (Also, it would have to be str[0..(str.size / 2)].index(' ')
> > but, still, it's no good).
>
> rindex()
>
> :)
>
> Regards,
>
> Bill

rindex, of course. Here's my current version then:

class String
  def halve
    i = self[0..(length / 2)].rindex(' ')
    if i.nil?
      if include?(' ')
        split(' ', 1)
      else
        [self, '']
      end
    else
      [self[0..i].strip, self[i..-1].strip]
    end
  end
end