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.
I believe this would work also
def reverse(str) string = '' (0..str.size-1).each do |i| string << str[str.size - 1 - i] end string end