Sunday 18 March 2012

palindrome in ruby

working with ruby code

simple method to check whether given string is palindrome. method will return true if the given string is palindrome or return false
 def palindrome?(string)  
   str=string.downcase;  
   str=str.gsub(/[^a-z]/,'');  
   return str.eql? str.reverse;  
 end