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.
Here's one way to do it with inject and unshift:
"Hello world".chars.inject([]) { |s, c| s.unshift(c) }.join