Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment