我是Ruby的新手.我有这样的数据:
year | month | foo
--------------------
2016 | 2 | 4
--------------------
2016 | 3 | 14
--------------------
... | ... | ...
--------------------
2017 | 12 | 9
Run Code Online (Sandbox Code Playgroud)
我想将该表存储在变量中,并且仍然能够使用年和月列的值访问列foo中的数据.就像是:
data['2016']['2']
Run Code Online (Sandbox Code Playgroud)
得到'4'.
有没有办法做到这一点?