如何在数组中的哈希内的数组内的哈希内访问数组?

时间:2015-04-10 18:05:19

标签: ruby

我得到一个返回值,如图所示。我认为它有一个包含在哈希等中的数组,

如何访问最里面的网络/数组中的元素? 类似于:p ret [0] .hash.array [0] .hash.array [0] .data我认为我错了解引用哈希。

p ret[0] works by returning me the hash but dont know how to go beyond that
p (ret[0])['network'] doesnt seem to work i think network is not a key, but how do i access that data structure ?

complicated return

1 个答案:

答案 0 :(得分:0)

如果你的返回值是这样的:

ret = [{ 'network' => ['something'] }]

你可以简单地说:

ret[0]['network'] #=> ["something"]