Ruby on rails Ruby-哈希、符号和字符串
我有返回下一个散列对象的gemRuby 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
{: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