Skip to content

Instantly share code, notes, and snippets.

@rubyginner
Created October 12, 2012 13:47
Show Gist options
  • Save rubyginner/3879276 to your computer and use it in GitHub Desktop.
Save rubyginner/3879276 to your computer and use it in GitHub Desktop.
Check if a word is palindrome or not
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