我是 Ruby 编程的初学者。我的程序是计算给定字符串中偶数长度的单词的数量。但它显示以下错误
[0, 0] 的未定义方法 '<' :Array
这是我的代码
def even(words, n)
i = 0, m = 0
while i < n do
count = count + words[i].length
if count%2 == 0 then
m = m + 1
end
i = i + 1
end
return m
end
prinnt "Enter The String:"
s = gets.chomp
words = s.split()
n = words.length
x = even(words, n)
puts x