Created
October 12, 2012 13:47
-
-
Save rubyginner/3879276 to your computer and use it in GitHub Desktop.
Check if a word is palindrome or not
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 palindrome?(word) | |
return (word == word.reverse) ? true : false | |
end | |
puts "Enter a word to see if it's a palindrome..." | |
word = gets.chomp | |
puts "The word #{word} is #{palindrome?(word.to_s) ? 'a' : 'not a'} palindrome." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment