gpt4 book ai didi

ruby - 合并运算符是官方 YAML 吗?

转载 作者:太空宇宙 更新时间:2023-11-03 16:23:42 25 4
gpt4 key购买 nike

我见过一些 YAML 文件使用“合并”运算符 << .这是来自 yaml.org 上“Yaml Cookbook”的示例:

mapping:
name: Joe
job: Accountant
<<:
age: 38

另一方面,我在 yaml.org 的规范文档中找不到任何对合并运算符的引用。

这个运算符是 YAML 的正式部分,还是只是 Ruby 实现的一部分?

最佳答案

http://yaml.org/type/merge.html

Specify one or more mappings to be merged with the current one.

The “<<” merge key is used to indicate that all the keys of one or more specified maps should be inserted into the current map. If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the current mapping, unless the key already exists in it. If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier in the sequence override keys specified in later mapping nodes.

更多信息在 http://yaml.org/type/

关于ruby - 合并运算符是官方 YAML 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29372209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com