John Smith John Smith - 5 months ago 8x
Ruby Question

Check if Hash is included in output

I am trying to check if a specific element is included in an output. I run:

results.include? {"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100}

but I get an error:

Syntax error, unexpected =>, expecting '}'

What did I do wrong?

ndn ndn

The problem is that the curly brackets in this case are interpreted as start of a block. Just put () around:

results.include?({"_id"=>{"car_id"=>44, "page"=>"5"}, "summarized_time"=>100})