除了注释行之外,一切似乎都运行良好:
#return false if not s[0].upcase =~ /AZ/
和第四次检查。
什么是正确的if
陈述s[0]
和/AZ/
比较?
def starts_with_consonant?(s)
return false if s.length == 0
#return false if not s[0].upcase =~ /AZ/
n = "AEIOU"
m = s[0]
return true if not n.include? m.upcase
false
end
puts starts_with_consonant?("Artyom") # false 1
puts starts_with_consonant?("rtyom") # true 2
puts starts_with_consonant?("artyom") # false 3
puts starts_with_consonant?("$rtyom") # false 4
puts starts_with_consonant?("") # false 5