作者:手机用户2502886741 | 来源:互联网 | 2023-02-04 16:18
I have the following hash:
我有以下散列:
a = {
foo: 'bar',
answer: '42'
}
How can I elegantly rename the key :foo
to a new key :test
? If the hash entry for :foo
does not exist, the hash should not be altered.
如何优雅地将key:foo重命名为新的key:test?如果:foo的散列条目不存在,则不应该修改散列。
1 个解决方案