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.
def reverse(string) reversed_string = "" idx = 0 while idx < string.length reversed_string = string[idx] + reversed_string idx += 1 end return reversed_string end