def reverse!(str)
arrayOfChars = str.split('')
index_left = 0
index_right = arrayOfChars.length - 1
while index_left < index_right
arrayOfChars[index_left], arrayOfChars[index_right] = \
arrayOfChars[index_right], arrayOfChars[index_left]
index_left += 1
index_right -= 1
end
return arrayOfChars.join('')
end
view raw inplace-reversal.rb hosted with ❤ by GitHub