Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby-哈希、符号和字符串_Ruby On Rails_Ruby_Gem_Rake - Fatal编程技术网

Ruby on rails Ruby-哈希、符号和字符串

Ruby on rails Ruby-哈希、符号和字符串,ruby-on-rails,ruby,gem,rake,Ruby On Rails,Ruby,Gem,Rake,我有返回下一个散列对象的gem {:response=>"There was an error authenticating the sender account.", :status_code=>401} 在我的rake任务中,我试图访问它的属性: response = my_gem.execute puts response puts response.has_key?(:respose) puts response[:respose] 但我不明白为什么会打印出来 {:res

我有返回下一个散列对象的gem

{:response=>"There was an error authenticating the sender account.", :status_code=>401}
在我的rake任务中,我试图访问它的属性:

response = my_gem.execute
puts response
puts response.has_key?(:respose)
puts response[:respose]
但我不明白为什么会打印出来

{:response=>"There was an error authenticating the sender account.", :status_code=>401}
false
为什么我不能用response[:respose]访问:response属性


p.S.response[response.keys.first]有效,但这是一个非常奇怪的解决方案

下面有一个输入错误:

puts response.has_key?(:respose)
has\u key.(:respose)
应该是
has\u key.(:response)


是的,漫长的工作日…:(@Olexandr碰巧我知道……休息一下,测试一下:))这个问题似乎离题了,因为它是关于打字/语法错误的
response = {:response=>"There was an error authenticating the sender account.", :status_code=>401}
response.has_key?(:response)
# => true