在GitHub上找到这个源代码:
def objects_from_response(klass, request_method, path, options={})
response = send(request_method.to_sym, path, options)[:body]
objects_from_array(klass, response)
end
对于这一特定行:
response = send(request_method.to_sym, path, options)[:body]
方法之后的[:body]
语法是什么?
答案 0 :(得分:3)
send(request_method.to_sym, path, options)
返回对象支持方法[]
,例如Hash
,然后在其上调用[:body]
。