title: YAML merge multiply anchors into the same map
body: <p>It is not clear if it is possible to use <a href="https://yaml.org/type/merge.html" rel="nofollow noreferrer">YAML merge key operator</a> several time for the same map.</p>
  <p>The confusion comes from:</p>
  <ul>
  <li><strong>merge key</strong> is only defined in outdated YAML 1.1 as an optional extension.</li>
  <li>there is no mentioning of it in <a href="https://yaml.org/spec/1.2/spec.html" rel="nofollow noreferrer">https://yaml.org/spec/1.2/spec.html</a></li>
  </ul>
  <p>Original spec says:</p>
  <blockquote>
  <p>The “&lt;&lt;” merge key is used to indicate that all the keys of one or more specified maps should be inserted into the current map.</p>
  </blockquote>
  <p>but they don't provide an example and I cannot find it elsewhere. Like:</p>
  <pre class="lang-yaml prettyprint-override"><code>defs:
  - map1: &amp;map1-ref
      key1: val1
  - map2: &amp;map2-ref
      key2: val2
  
  config:
    database:
      &lt;&lt;: *map1-ref
      &lt;&lt;: *map2-ref
      key3: val3
  </code></pre>
  <p>Which major parsers support multiply merges (python/ruby/java/node)?</p>
  <p><strong>UPDATE</strong> Python 3 check code:</p>
  <pre class="lang-py prettyprint-override"><code>import yaml
  with open(&quot;my.yml&quot;) as f:
      y = yaml.safe_load(f)
      print(y)
  </code></pre>
  <p><strong>UPDATE 2</strong> <strong>@flyx</strong>'s suggested syntax can be written in an alternative way:</p>
  <pre class="lang-yaml prettyprint-override"><code>config:
    database:
      &lt;&lt;:
        - *map1-ref
        - *map2-ref
      key3: val3
  </code></pre>