Ruby 字符串回文判断

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

def is_palindrome(word)
  if word == word.reverse
   "#{ word } is a palindrome."
  else
   "#{ word } is not a palindrome."
 end
end

# Example implementation:
puts is_palindrome("racecar") 
# This would return "racecar is a palindrome."
puts is_palindrome("penis")
# This would return "penis is not a palindrome."