{"or"=>"@`"...">

Undefined method has_key?

When trying to deal with a nested hash in ruby, I get this error:

undefined method `has_key' for {"_l"=>{"or"=>"@`"}, "a"=>{}}:Hash (NoMethodError)

- this is not what the pros refer to above ... hash? do not hashes have a has_key method? ()? what's going on here?

Here is the code ... thanks:

$conditioning_environments = {
  "_l" =>
   {
    "or" => "@`"
   },
     "a" => {

   }
}
....
if $conditioning_environments["_"+graphemes[index+1]].has_key(g)
    ....
+3
source share
1 answer

The method you want has_key?with a question mark.

The inserted fragment has a question mark, but an error indicates the absence in the problem code.

EDIT: you removed the question mark from the inserted snippet: p

+12
source

All Articles