<<:
operator <<:
in YAML, you can import the contents of one mapping into another, similar to the double-splat **
operator in the Python object destruction operator or ...
in JavaScript. For instance,
foo: a: b <<: c: d e: f
equivalently
foo: a: b c: d e: f
This is useful when used with node anchors to include some common default properties in many objects, as shown, for example, Learn YAML in Y minutes :
# Anchors can be used to duplicate/inherit properties base: &base name: Everyone has same name foo: &foo <<: *base age: 10 bar: &bar <<: *base age: 20
However, I am confused about where this syntax comes from, or why it works. CTRL + F in the YAML specification for <<
indicates that it does not appear anywhere in the specification. However, it is supported by at least PyYAML and http://yaml-online-parser.appspot.com/ .
What is this syntax, and why does it not appear in the specification?
source share