这怎么可能?Ruby if循环失败

这怎么可能?Ruby if循环失败,ruby,Ruby,我不明白这是怎么回事: (byebug) missing_association_words.include?(@mtw.first.word) false (byebug) @mtw.first.word text (byebug) missing_association_words text 这段代码返回false,尽管两者包含相同的值。如果要检查第二个数组中的值是否也包含在第一个数组中,可以使用以下方法: (first_array & second_array).an

我不明白这是怎么回事:

 (byebug) missing_association_words.include?(@mtw.first.word)
 false
 (byebug) @mtw.first.word
 text
 (byebug) missing_association_words
 text

这段代码返回
false
,尽管两者包含相同的值。

如果要检查第二个数组中的值是否也包含在第一个数组中,可以使用以下方法:

(first_array & second_array).any?

都是
@mtw。首先。字符串类的word
缺少关联词
?也值得检查
文本
后的空格。
缺少关联词
是一个数组,而
@mtw
也是一个数组。你能发布它们吗?你实际上是在比较两个数组的相同值。我贴了一个答案你怎么能做到