Ruby 组合哈希中的元素
我有一个看起来像这样的:
data = {abc -> [[date1, val1], [date2,val2]], def -> [[date1,val3], [date2,val4]]}
我想加入 abc 和 def 元素,所以它是这样的:
data = {join -> [[date1, val1+val3], [date2, val2+val4]] }
我该如何去做。请注意,哈希中还有其他不应修改的元素。
I have a has that looks like this:
data = {abc -> [[date1, val1], [date2,val2]], def -> [[date1,val3], [date2,val4]]}
I want to join the abc and def elements so it's like this:
data = {join -> [[date1, val1+val3], [date2, val2+val4]] }
How do I go about this. Note that there are other elements in the hash that should not be modified.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设
abc
、def
和join
实际上是符号。I am assuming that
abc
,def
, andjoin
are actually Symbols.