Podaję treść zadania i pod spodem moje rozwiązanie. Czy ktoś może mi powiedzieć co powinnam dopisać do polecenia : if word == word.reverse tak, żeby palindrome?("Racecar") też było true?
A Palindrome is a word or phrase which reads the same backward or forward, such as madam or kayak.
Implement a Ruby method palindrome? that checks if a given word is a palindrome
This method should take one argument (word), a String, and return a Boolean (true or false), telling us if the given word is a palindrome or not. You can assume the one argument is a single word. It should not be affected by capital letters.
palindrome?("racecar") should return true
palindrome?("Racecar") should return true
palindrome?("wagon") should return false
Moja odpoweidź:
def palindrome?(word)
if word == word.reverse
return true
else
puts "This word is not a palindrome."
end
end
palindrome?("racecar")
palindrome?("Racecar")
palindrome?("wagon")