开发者

multiple keys for one value in yaml

开发者 https://www.devze.com 2023-01-26 17:39 出处:网络
Is it possible to use different keys for the same value? [开发者_JAVA百科activerecord, activemodel]: \'test\'

Is it possible to use different keys for the same value?

[开发者_JAVA百科activerecord, activemodel]: 'test'

I expect the same result as with this:

activerecord: 'test'
activemodel: 'test'


That doesn't work because YAML allows you to specify keys of any type, so

[activerecord, activemodel]: 'test'

is a mapping with a single key, the sequence [activerecord, activemodel] whose value is 'test'.

Instead, you can use an anchor/alias:

activerecord: &my_value 'test'
activemodel: *my_value

However, there's no way of attaching both keys to the single value in one key/value pair.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号