在ruby方法中返回包含数组和散列的数组?

Mo.*_*Mo. 3 ruby ruby-on-rails

您好

是否可以从ruby中的方法返回包含数组和散列的数组?

def something
array_new = [another_thing, another_thing_2]
hash_map = get_hash()

return [array_new, hash_map]

end
Run Code Online (Sandbox Code Playgroud)

并检索数组:

some_array, some_hash = something()
Run Code Online (Sandbox Code Playgroud)

谢谢

sep*_*p2k 5

当然,这完全可能,并且与您的示例完全一样.