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.
A simple classic way with n/2 complexity
str = "Hello World!"; puts str; for i in 0..(str.length/2).to_i mid = (str.length-1-i); temp = str[i]; str[i] = str[aa]; str[aa] = temp; end puts str;