这是我的示例代码
:key1 => "a"
:key2 => "b"
:key3 => "c"
array1 = [[:key1, :key1, :key1],[:key1, :key2, :key3],[:key2, :key2, :key1]]
array1.each { |x| if x.sym_tos == "a"
puts "All match!"
else
puts "no match"
end
}
然而,当我运行它时,我收到以下错误代码: 用于[:R1C1,:R1C2,:R1C3]的未定义方法`sym_to_s':数组(NoMethodError)
答案 0 :(得分:2)
你可能想说
if x.uniq.length == 1