Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#validate_palindrome?(something) ⇒ Boolean

Validate if the word or sentence is a palindrome Params:

something

It is the string to validate.

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
# File 'lib/validatepalindrome.rb', line 6

def validate_palindrome?(something)
  if something.empty?
    print "Write something : "
    something = gets
  end
  something.gsub!(/\s+/,"") #Removes white spaces
    puts something
  puts something.reverse
  puts something == something.reverse ? "Es Palindromo" : "No es Palindromo"
end