RosettaCodeData/Task/Palindrome-detection/Ruby/palindrome-detection-2.rb

10 lines
126 B
Ruby
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
def r_palindrome?(s)
if s.length <= 1
true
elsif s[0] != s[-1]
false
else
r_palindrome?(s[1..-2])
end
end