Created
January 26, 2012 05:54
-
-
Save vinhboy/1681265 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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