我正在尝试检查输出中是否包含特定元素。我跑:
results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}
但是我收到了错误:
Syntax error, unexpected =>, expecting '}'
我做错了什么?
答案 0 :(得分:2)
问题是这种情况下的花括号被解释为块的开头。只需放置()
:
results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})