How do you reverse a string in Ruby? I know about string#reverse. I\'m interested in understanding how to write it in pure Ruby, preferably an in-place solution.
This is the solution that made the most sense to me as a ruby beginner
def reverse(string)
reversed_string = ''
i = 0
while i < string.length
reversed_string = string[i] + reversed_string
i += 1
end
reversed_string
end
p reverse("helter skelter")