Skip to content

Instantly share code, notes, and snippets.

@vinhboy
Created January 26, 2012 05:54
Show Gist options
  • Save vinhboy/1681265 to your computer and use it in GitHub Desktop.
Save vinhboy/1681265 to your computer and use it in GitHub Desktop.
def flip(input)
puts "What are we flipping? "
input = gets
input.chomp!
# the last letter position
length = input.length - 1
# the first letter
first = input[0]
# the lat letter
last = input[length]
# replace the first letter with the last
input[0] = last
# replace the last letter with the first
input[length] = first
puts input
end
flip("testing")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment