我正在开发一个ruby应用程序,我需要连接多个send方法调用以访问带有一组键的复杂哈希。为了使用send方法访问哈希的元素,我一直在使用Hashugar gem。例如:
hash = { one: 1, two: 2, more: [{ three: 3}, {four: 4}] }.to_hashugar
keys = ['more', 'first', 'three'] # 'first' is the first elements of the array
hash.send( *keys ) # FAIL
我一直在尝试不同的方法让它发挥作用,但我无法做到。有没有可能实现这个目标?如果我需要删除Hashugar并不重要。
提前致谢。