I try to implement my own reverse string method:
def string_reverse(string)
half = string.length / 2
half.times do |i|
string[i] = string[-i-1]
string[-i-1] = string[i]
end
end
But it only reverses the first half of the string. What am i missing here?
fail "couldn't reverse foo, got #{string_reverse('foo')}" unless string_reverse("foo") == "oof"