14
对于相同的值可以使用不同的键吗?yaml中的一个值的多个键
[activerecord, activemodel]: 'test'
我期待相同的结果与此:
activerecord: 'test'
activemodel: 'test'
对于相同的值可以使用不同的键吗?yaml中的一个值的多个键
[activerecord, activemodel]: 'test'
我期待相同的结果与此:
activerecord: 'test'
activemodel: 'test'
这并不工作,因为YAML允许你指定的任何类型的钥匙,因此
[activerecord, activemodel]: 'test'
是一个映射使用单个密钥,其值为'test'
的序列[activerecord, activemodel]
。
相反,你可以使用一个锚/别名:
activerecord: &my_value 'test'
activemodel: *my_value
然而,有没有在一个键/值对两个键的单值连接的方式。